RE: [PHP] Which file called the function?

From: Date: Mon, 31 Dec 2007 20:37:15 +0000
Subject: RE: [PHP] Which file called the function?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-266440@lists.php.net to get a copy of this message
On Thu, December 20, 2007 1:54 pm, George Pitcher wrote: > I have a functions file with over 400 functions (and that may be too > many - > but it works). I've been adding some error reporting in to my PEAR::DB > queries, but wanted to know which page triggered the function. I went > theough my php pages and gane each one a $pg variable at the start > containing the bare name of the file, eg 'home' rather than > 'home.php'. I > then went to each function containing either a DB query (ore one which > calls > another DB-related function. I did a global search and replace for the > function name 'func(' replaced by 'func($pg,'. I use Dreamweaver so > this was > fairly straightforward. > > It worked for me, but now someone is about to show me a quicker, > cleaner > way, aren't they? FIRST LINES OF CODE: <?php function error_handler($code, $message, $file, $line, $context){ die("ERROR: $message ($code) in $file:$line"); } set_error_handler('error_handler'); ?> Anywhere else in your code: [examples] $connection = mysql_connect(...) or trigger_error("No DB access.", E_USER_ERROR); -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So?

« previous php.general (#266440) next »