error handling and __LINE__
| From: | SafeV | Date: | Thu, 22 Nov 2001 15:15:51 +0000 |
| Subject: | error handling and __LINE__ | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-75514@lists.php.net to get a copy of this message | ||
Hi,
I wonder if there's a way to find the line number of the calling script from a function, like the error messages PHP generates. An example:
In an included file I have a function and want to do something similar to:
function foo($obj) {
if (!is_object($obj)) {
echo "Error: supplied argument is not an object in ";
echo __FILE__ . " line " . __LINE__;
}
...
}
But __FILE__ and __LINE__ refers to the current file, ie. the file with the function in, and not the file where the function is called from.
The first one I can solve by using $SCRIPT_NAME, but what about the line number???