- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
The string mangling functions make it look like their background (or misguided desire) is functional programming. But then their reimplementation of functions that already exist just makes it look like they're stupid.
Oh, and maybe frist?
Admin
If an implementation does something different it is not a re-invention.....
Admin
Where does str2int turn into a busy loop? The invariant is $i++, and it will eventually stop once $i is $length. Or am I overlooking something?
Admin
The HDD which stores the repository of that legacy code should immediately be thrown into a bonfire, around which the devs should dance to celebrate the purging of their codebase and to exorcise the demons of bad code.
Admin
Nah, skip the date functions. The fact that they exist in the code is WTF enough.
Admin
C'mon! Everyone knows it's faster to recode features from other languages than to RTFM!
Admin
singlequote()
is useful for things likearray_map('singlequote', $array);
. Although it's likely that this is being used when substituting into a SQL query, and you should use prepared statements instead.Admin
@Melissa U: When $concat_flag becomes false, neither of the conditions can be true, so it's pointless to continue looping. The smart thing to do would be to break out of the loop.
Admin
I want to weep just because this is so effing common.
Admin
I don’t know how PHP does ternaries, but I think the iif function is going to evaluate both $a and $b regardless of the condition, whereas a bare ternary (in other languages) would only evaluate one or the other. So you can’t use it for short-circuit evaluation.
Admin
Little Bobby Tables ( https://xkcd.com/327/ ) was my first thought when I saw the single quote function as well.
Admin
The iif might not be the programmer's background but the code's. Perhaps some sort of auto translator?
Admin
Remember that php ternaries are evaluated right-to-left unlike in other languages, meaning that the
iif
fiction might actually behave more as expected. Unless lazy evaluation is expected, as another poster points out.Admin
But
iif
uses a ternary. Why would PHP evaluate both arguments just because the ternary is wrapped in a function?You know what, I will only be somewhat surprised if it does.
Addendum 2022-10-13 13:48: EDIT: ah you know what, I guess they will be evaluated before being passed into the function.
If this matters, that's even more WTF.