275
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 48 points 1 year ago

The fault is the programmer for not using a switch statement.

[-] [email protected] 52 points 1 year ago

"php doesn't stop me from coding like a moron, therefore php sucks"

[-] [email protected] 2 points 1 year ago

I say that php breaks math entirely, and is therefore bad. "" == null returns true null == [] returns true "" == [] returns false.

In more recent versions it gets worse, because it has 0 == "any text" return true, "any text" == true return true, and 1 == true return true So indirectly 1 = 0, and now math is more directly broken.

[-] [email protected] 2 points 1 year ago

I just tested these out out of curiosity.
0=="text" returns false in PHP 8.2 as I'd expect.

The others make sense in the way that php juggles between types. An empty variable can type-juggle to null, but an array can't be directly compared with a string.

(Although you wouldn't really want to compare an array with a string, PHP just treats an array as greater than other variables. So weirdly, ([] > "") == true.)

load more comments (3 replies)
load more comments (6 replies)
load more comments (6 replies)
this post was submitted on 14 Jul 2023
275 points (90.1% liked)

Programmer Humor

32070 readers
498 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS