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:
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 !=).
April 1, 2009 at 12:29 pm
Now, y’see… some of us would argue that the runtime should defend against that at compile time, on general principles.
Oh, wait. PHP. Principles. Yes, I think I see the problem.
April 1, 2009 at 2:51 pm
It’s another example of the difference between OS and App coders … most of your "bedroom coders" have probably never even looked in the log files, if they know they exist. As long at they don’t get an http 500 error when they run their latest webapp, they don’t care …
Me, I do everything, and look in the log files first.. hate them getting full of error messages. And who made browsers look for bloody favicons on seemingly every access…..?!?!!
As for next week, you might touch on the difference between = and == within an IF too …. that particular typo bit me recently.. took ages to find.
April 1, 2009 at 7:03 pm
Can’t you put an @ sign before it to turn off the warnings or something? That sounds better. Can I get a job now?
April 13, 2009 at 5:37 pm
you promised a subsequent rant and did not deliver.
this is not like you.