Automatically register / register request URI as part of an error in PHP?

Is there a way to get the request URI automatically added to the error_log() output? The errors currently look like:

 [03-Dec-2012 13:56:22] PHP Fatal error: Call to a member function getStories() on a non-object in /usr/share/php/MyProject/Model/Index.php on line 148 

Is there any way to get the url there?

+4
source share
1 answer

Hope this helps:

  function debugErrorHandler($errno, $errstr, $errfile, $errline) { if(error_reporting()!==0) { switch($errno) { default: error_log("PHP Warning Debug: Server Request URI: " . print_r($_SERVER["REQUEST_URI"], true)); break; } return false; // false -> Execute PHP internal error handler } } 
0
source

All Articles