how to achieve functionality of #def of c in PHP
Posted
by Sabya
on Stack Overflow
See other posts from Stack Overflow
or by Sabya
Published on 2010-06-10T07:26:46Z
Indexed on
2010/06/10
7:32 UTC
Read the original article
Hit count: 210
Well, I don't know if thats what I want. But here is my problem:
In case of some error I am logging the FILE, CLASS, FUNCTION and LINE in a file. For that I am doing something like:
myLog('['. __FILE__ . ']' . '[' . __CLASS__ . ']' . '[' . __FUNCTION__ . ']' . '[' . __LINE__ . ']');
The problem is everywhere I've to repeat that code in the parameter. and If I want to change the format, I've to change everywhere.
How can I have something like:
myLog(LOG_MSG_FORMAT);
With PHP define it is not possible since it will give my the LINE number of the place where that definition is, not where the definition is getting used.
Any solution to this is welcome. I am not bitchy about having C like functionality of #def.
© Stack Overflow or respective owner