Entry
Is there a way of forcing PHP to require explicit variable declaration, as in PERL with "use strict" ?
Jun 27th, 2004 21:20
Philip Olson, Richard Lynch, b linc,
While you can't get PHP to completely die on an instantiated variable,
you can set your error reporting higher [then the default] in php.ini or
using the error_reporting() function at runtime.
Undeclared variables produce errors of level E_NOTICE and E_NOTICE
errors are by default [default php.ini is php.ini-dist] hidden by PHP.
At runtime you may append the following to show ALL types of errors,
including E_NOTICE:
error_reporting(E_ALL);
And/or in php.ini you'd have:
error_reporting = E_ALL
In PHP 5 there is a new error level appropriatly named E_STRICT that
adds even more errors. E_STRICT is NOT included in E_ALL so to use it
you'd do something like:
// This will show ALL errors
error_reporting(E_ALL | E_STRICT);
See also your php.ini file and the manual:
http://www.php.net/error-reporting
And remember to show errors on output (to your browser) you'll need the
display_errors directive set to on or simply use error logs.