What Jessie Did Next...

...being the inane ramblings of a mundane Yorkshire bird.

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 !=).

4 Comments

  1. 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.

  2. 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.

  3. Can’t you put an @ sign before it to turn off the warnings or something? That sounds better. Can I get a job now?

  4. you promised a subsequent rant and did not deliver.

    this is not like you.

Leave a Reply

Your email address will not be published.

*