View. You can activate the E_NOTICE
level in your bug report . (The list of constants is here .)
Each use of the undeclared variable E_NOTICE
.
E_STRICT
errors E_STRICT
will give you these notifications as well as other tips on how to optimize your code.
error_reporting(E_STRICT);
Script completion
If you are really serious and want your script to exit rather than just display a notification when an undeclared variable is detected, you can create your own error handler .
A working example that processes only E_NOTICE
with an "undefined variable" in them and passes everything else to the default PHP error handler:
<?php error_reporting(E_STRICT); function terminate_missing_variables($errno, $errstr, $errfile, $errline) { if (($errno == E_NOTICE) and (strstr($errstr, "Undefined variable"))) die ("$errstr in $errfile line $errline"); return false;
Pekka ์ Jul 07 '10 at 8:29 2010-07-07 08:29
source share