note 53277 deleted from language.constants by danbrown
| From: | danbrown@php.net | Date: | Tue, 26 Jul 2011 20:04:49 +0000 |
| Subject: | note 53277 deleted from language.constants by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-181910@lists.php.net to get a copy of this message | ||
Note Submitter: ck
----
Re: Storm.
I ran that code (in PHP4)
<?php
if (DEBUG) {
// echo some sensitive data.
}
?>
and saw this warning:
"Use of undefined constant DEBUG - assumed 'DEBUG'"
A clearer workaround is to use
<?php
if (defined('DEBUG')) {
// echo some sensitive data.
}
?>
Thanks for pointing out this big gotcha.
Another reason to turn on warnings during testing. Good web servers are set up to suppress warning
and error output to the browser, so this is handy:
<?php
if (defined('DEBUG')) {
error_reporting(E_ALL);
set_error_handler('debug_ErrorHandler');
}
function debug_ErrorHandler($errno, $errstr, $errfile, $errline) {
print("PHP Error [$errno] [$errstr] at $errline in $errfile.<br>");
}
?>