I do not know one thing. See the code below. There is a function to display all defined functions . There is another to get the values โโof all the arguments of the current function , and the number of arguments . And there is one to see if the function exists . But, it seems, there is no name for the current function or any means for listing formal parameters.
Even when a run-time error occurs, it does not display the call stack and does not indicate the active function:
PHP Warning: Division by zero in t.php on line 6
Edit: to determine the code where it is, add the following:
echo "At line " .__LINE__ ." of file " . __FILE__ ."\n";
He outputs
At line 7 of file /home/wally/t.php
Edit 2: I found this function in my code that looks the way you want:
function traceback ($showvars) { $s = ""; foreach (debug_backtrace($showvars) as $row) { $s .= "$row[file]#$row[line]: "; if(isset($row['class'])) $s .= "$row[class]$row[type]$row[function]"; else $s .= "$row[function]"; if (isset($row['args'])) $s .= "('" . join("', '",$row['args']) . "')"; $s .= "<br>\n"; } return $s; }
For example, it produces:
[ wally@zf ~]$ php -f t.php /home/wally/t.php#24: traceback('1')<br> /home/wally/t.php#29: t('1', '2', '3')<br> /home/wally/t.php#30: x('2', '1')<br> /home/wally/t.php#31: y('2', '1')<br> /home/wally/t.php#33: z('1', '2')<br>
source share