How to achieve functionality of #def of c in PHP?

As others said, you can use debug_backtrace to find out the calling location of your log function. Debug_backtrace is quite inconsistent, therefore there is some trickery involved, here's an example: helper function e($a, $k, $d = null) { return isset($a$k)? $a$k : $d; } function mylog($msg) { $t0 = e(debug_backtrace(), 0); $t1 = e(debug_backtrace(), 1); $header = sprintf("%s:%s (%s:%s)", e($t1, 'class', 'global'), e($t1, 'function', 'unknown'), e($t0, 'file'), e($t0, 'line')); $_ = func_get_args(); $s = $header .': ' .

Vsprintf(array_shift($_), $_); echo $s, "\n"; // or error_log } As a free bonus, my_log also accepts a parameter list in printf style, e. G my_log("send mail to=%s subject=%s time=%d", $to, $subject, time()).

As others said, you can use debug_backtrace to find out the calling location of your log function. Debug_backtrace is quite inconsistent, therefore there is some trickery involved, here's an example: // helper function e($a, $k, $d = null) { return isset($a$k)? $a$k : $d; } function mylog($msg) { $t0 = e(debug_backtrace(), 0); $t1 = e(debug_backtrace(), 1); $header = sprintf("%s:%s (%s:%s)", e($t1, 'class', 'global'), e($t1, 'function', 'unknown'), e($t0, 'file'), e($t0, 'line')); $_ = func_get_args(); $s = $header .': ' .

Vsprintf(array_shift($_), $_); echo $s, "\n"; // or error_log } As a free bonus, my_log also accepts a parameter list in printf style, e.g. My_log("send mail to=%s subject=%s time=%d", $to, $subject, time()).

PHP has no preprocessor like C. But you could use your own error handler and use the already mentioned debug_backtrace in it to get the required information.

Edited the question. – Sabya Jun 10 '10 at 9:09.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions