Stack Overflow Code WTF

  1. Comments

If you try to hang around Stack Overflow for a while watching questions and answers there, you'll surely go postal. Sometimes I can't trust my eyes. WHAT someone have to have in their mind to produce a code like that?

So I decided to start collecting such WTFs.

  1. My favorite ingenious function. Note that the author's intent was not to remove null values, which would have made at least some sense, but to remove keys that do not exist in the array, as it was asked in the OP (to prevent 'Unefined index error'). Just hilarious.
  2. That's a link to my own answer, which explains why the accepted answer is ridiculously wrong. And you may compare the voting. NB! Please to not correct the voting! I am by no means is after any reputations points, and what I want is to keep this post as illustrative as it is at the moment (46/-1).
  3. A somewhat petty issue, the guy confused a reference with a resource. The most funny part is the initial voting. This post had +7 score. Again, you can make a picture of a regular SO participant and their habit of voting.
  4. Again, it is voting that makes you WTF?! The answer is outright wrong, current(), as the name suggests, is giving you the current element, not the first one as it was asked in the OP. Same for the key() as well.
  5. The initial voting weren't that high, but the answer is still essentially wrong: the very difference of mysqli_insert_id() from LAST_INSERT_ID() is that the former won't give you an id from the last successful query but from the very last insert query, as it said in the manual. The sad part here, mods deleted my comment explaining this stuff and asking the guy to delete this answer so not to confuse people. Why mods are so determined in keeping this shit intact is a puzzle.

Related articles: