Undefined Variables In PHP
Once again I find myself cleaning up undefined variables referenced in PHP. Yet more bedroom coders who think they can write stuff, causing notices, errors and warnings to spew out just simply because they can't be arsed to learn to use isset().
THIS IS WRONG:
THIS IS RIGHT:
For crying out loud, is it any fucking wonder PHP gets such a bad rap when you bloody idiots are making vague assumptions about undefined values being FALSE? I should set fire to every bastard one of you.
(Next week's rant: !== vs !=).
THIS IS WRONG:
if ( ! $_REQUEST['blah'] ) {
echo "thingy isn't set";
}
THIS IS RIGHT:
if ( ! isset($_REQUEST['blah']) ) {
echo "thingy isn't set";
}
For crying out loud, is it any fucking wonder PHP gets such a bad rap when you bloody idiots are making vague assumptions about undefined values being FALSE? I should set fire to every bastard one of you.
(Next week's rant: !== vs !=).
Oh, wait. PHP. Principles. Yes, I think I see the problem.
Peter Crowther • 01 April, 2009 • 12:29:22