php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #21155 Macro Request
Submitted: 2002-12-22 22:45 UTC Modified: 2010-12-21 19:16 UTC
Votes:4
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:2 (50.0%)
From: james at grickle dot org Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 4.2.3 OS: Slackware-current (12/22/02)
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: james at grickle dot org
New email:
PHP Version: OS:

 

 [2002-12-22 22:45 UTC] james at grickle dot org
Hello,

I would like to request something along the lines of macros. It would help a lot when you need to run __LINE__ and/or __FILE__ constants through a function.

A simplified version of what I'd need them for. Currently I have:
errOut([severity], [message]);

Every time I use errOut I have __FILE__ and __LINE__ in the message:
define(FATAL, 7);
errOut(FATAL, __FILE__ . ": " . __LINE__ . ": Database error bla bla bla");

It could be shortened up by something like this:
mdefine("DOERR", "errOut($1, __FILE__ . ': ' . __LINE__ . ': ' . $2)");
DOERR(FATAL,"Database Error bla bla bla");

This could be used for more vital things than that of course. Anything along those lines would be great.

Thank You,
James Harr

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-26 09:44 UTC] helly@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

Maybe it would, but that is not the way __FILE__ and __LINE__ work. Simply use them as they are now: They always return the current file and line - no more no less.
 [2003-04-27 09:41 UTC] james at grickle dot org
__LINE__ and __FILE__ were just meant to be used as an example of how a macro feature might be used

I intended it to be more of a preprocessor. So where ever it sees:

DOERR(FATAL,"Database Error......");

it would replace it with

errOut(FATAL, __FILE__ . ': ' . __LINE__ . ': ' . "Database Error......");

So __FILE__ and __LINE__ would actually be in the file and line the macro would be at. Using it much in the same way as the C preprocessor is/can be used.
 [2010-12-21 19:16 UTC] johannes@php.net
-Status: Open +Status: Bogus -Package: Feature/Change Request +Package: *General Issues
 [2010-12-21 19:16 UTC] johannes@php.net
For errors you could use trigger_error89 plus an error handler. Having a "pre processor" for the "PHP Hypertext Preprocessor" doesn't have many benefits besides complexity.

Some people were experimenting with http://pecl.php.net/package/PreProcessor or build systems (ant, phing, ...) doing such substitutions, though. But nothing proved to be useful.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 20:01:30 2024 UTC