Stack Overflow Code WTF
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.
- 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 'Undefined index error'). Just hilarious.
- 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).
- 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.
- 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.
- The initial voting weren't that high, but the answer is still essentially wrong: the very difference of
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.
- My own answer again that is basically a WTF about the accepted answer that helps the OP to take a steady aim and shoot himself in a foot.