note 60224 deleted from function.set-error-handler by nlopess

From: Date: Fri, 30 Dec 2005 12:50:08 +0000
Subject: note 60224 deleted from function.set-error-handler by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-100988@lists.php.net to get a copy of this message
Note Submitter: marcel dot schnippe at nospam dot provinal dot com Reason: useless ---- If you are debugging json or ajax applications, you may find the following error handler usefull. It should be used for php generated javascript files only. The html-tags are just meant to be a display hint for a webbrowser when it does not know it is displaying javascript. Please understand that the error message is only shown by the browsers js interpreter, if the instruction flow passes the position of the error. If you don't have php-json (you should get it from http://www.aurore.net/projects/php-json/) remove the line with 'json_encode' or use an encoder of your own choice. <?php function myErrorHandler($errno, $errstr, $errfile, $errline, $context) { $a = "/*<b>PHP Error Handler:</b><pre>*/\nalert('PHP"; $e = "\\n".addslashes($errstr).'\\n'; $e.= " =>In line $errline of file ".addslashes($errfile)."');\n"; $e.= 'alert (\'Context:'.str_replace ('\\n',"\\n'+\n'",json_encode (print_r ($context,true)))."');\n"; $e.= "debugger;<*</pre>*/"; switch ($errno) { case E_ERROR: echo "$a ERROR: $e"; exit(1); case E_WARNING: echo "$a WARNING: $e"; exit(1); case E_NOTICE: echo "$a NOTICE: $e"; break; default: echo "$a OTHER($errno): $e"; } } ?>

« previous php.notes (#100988) next »