Trying to use __FILE__ & __LINE__ in generic debugging routine.
| From: | Neil Kimber | Date: | Sun, 05 Nov 2000 16:01:56 +0000 |
| Subject: | Trying to use __FILE__ & __LINE__ in generic debugging routine. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-23791@lists.php.net to get a copy of this message | ||
I want to write a debug routine that outputs my debug comments wherever I
want. So, for example I may want to write:
myDebug("Adding customer to database.");
What would be most useful is if I could also output the file and line number
that generated the comment. I can do this with:
myDebug(__FILE__ . __LINE__ . ": Adding customer to database.");
But, I don't want to have to keep on typing '__FILE__ . __LINE__'. If this
were C I could define a value for the preprocessor to resolve (i.e. #DEFINE
DBOPTIONS __FILE__ . __LINE__ .) But I can't do this in PHP. Is there any
other way that I can define my debug routine so that I can output the File
and Line number without having to keep specifying them directly?
The perfect solution would enable me to write simply:
myDebug("Adding customer to database.");
Thanks,
Neil