Entry
Is there perl like 'strict' swicth to php
Mar 13th, 2000 18:30
Kris Erickson, Jani Averbach, http://www.php.net/manual/function.error-reporting.php3
The closest thing to 'strict' in PHP is setting error_reporting to
E_ALL.
This will warn you of instances where you are comparing values before
they are set, and similar questionable situations that may be typos.
I.e.
$var1 = "foo"
if ("foo" == $varl) {
do_something();
} else {
do_nothing();
}
will be caught with a warning that you are trying to compare a variable
before it is set. However due to the nature of PHP (you cannot declare
variables, only initialize them) there really can be nothing exactly
the same as strict.
NOTE: error_reporting seems to have a lot of issues in PHP4betas on
Unix. It seems to setting at the beginning of a script seems to set
error reporting for PHP on the server and can only be reset by
restarting apache. This may be fixed by now, but it has been an issue
in the past.