Re: Function Call Line Number

From: Date: Thu, 15 Nov 2001 15:57:52 +0000
Subject: Re: Function Call Line Number
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-74727@lists.php.net to get a copy of this message
Jason G. wrote: > Does anyone know of a way, that from within a function, you can determine > what line number and file the function was called on? Cannot be done with existing built-in PHP functions... Feel free to add that feature to the PHP source and contribute it :-) > I did try: > function myfunc($lineno = __LINE__) > { > echo $lineno; > } > but this just outputted the very line that __LINE__ resides on. > > This would be very helpful in displaying sensible error messages, like the > native php functions do. If you use http://php.net/set_error_handler properly, you can get what you want, though. That lets you register a function to be called in the event of an error, and it has optional arguments you can provide to get the __FILE__ and __LINE__ values. -- Like music? http://l-i-e.com/artists.htm

« previous php.general (#74727) next »