Function call stack
| From: | Christian Novak | Date: | Wed, 30 Jan 2002 11:33:35 +0000 |
| Subject: | Function call stack | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-82717@lists.php.net to get a copy of this message | ||
Has anyone an idea on how to get information from PHP on the function call
stack.
I need the line number and file calling a function for a custom error
handler.
To be more clear, here is what I would like to do:
- I have a library, included in the main program
- I have an error handler in the library
// main.php
require "library.php";
$x = myfunc('A');
// library.php
function myfunc($i)
{
if (!is_int($i)) {
$file = ???? // how can I get the file name of the file
calling myfunc()
$line = ???? // how can I get the line number of the file
calling myfunc()
trigger_error("Error in $file, at line $line, paramter must be an
integer!", E_USER_ERROR);
return($i);
Using the pre_defined varibales __line__ and __file__ will always point me
to the function not the calling
script.
Best regards
Christian Novak