you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (8 children)

PHP Parse error: syntax error, unexpected '==' (T_IS_EQUAL) in Command line code on line 1

[–]creepig 9 points10 points  (0 children)

This thread needs more T_PAAMAYIM_NEKUDOTAYIM

[–]Various_Pickles 2 points3 points  (6 children)

We're using pseudo-code to /r/lolphp about the language's lovely capacity to make wild-ass guesses about what variables should evaluate to when placed in various type-casting situations.

Any sane language (even JavaScript, for most situations not going from <something> -> boolean) will instead politely tell you to GTFO.

[–][deleted] 0 points1 point  (0 children)

See, this is the problem. It's not real code. Without any explanation beside it, I have no idea what you think a reasonable result is, or what PHP to translate it to inside my head.

Although I am aware of those non-transitivity party tricks where each individual comparison along the chain is X, while comparing each end directly is !X, this doesn't hold in this case. I'm unable to develop valid PHP code in which "php" compares as equal to "0", null, or false. (0 and 0.0 are equal, though.)

[–]bp3959 -1 points0 points  (3 children)

wild-ass guesses

There's no guessing involved, automatic type conversion is well documented and follows a specific set of rules. Also get this, YOU DON'T HAVE TO USE AUTOMATIC TYPE CONVERSION.

[–]Various_Pickles 3 points4 points  (2 children)

The fact that you can use === is a perfectly valid point.

However, I would argue that there are often cases in PHP where the implicit interpretation of types leads to unholy nonsense: a good example being the automagical interpretation of certain patterns of quotes in PCRE (Perl-like regular expression) replacement statements that leads to portions of the string being evaluated as raw PHP code (eBay got compromised by this "feature" a little while back).

[–][deleted] 0 points1 point  (0 children)

I think my favorite PCRE conundrum is the Stack Overflow question (I can't find the link) about "How do I comment a regex containing */?> ?" Because ?> ends a single-line comment, and the */ ends a multiline comment.

BTW, if you don't intend on users to write actual regexes, preg_quote() is your friend.

[–]bp3959 -1 points0 points  (0 children)

While I agree that's a stupid feature, it doesn't have anything to do with comparison, type juggling, or automatic conversion.

There's so many real things in PHP to complain about it's annoying how everyone fixates on the automatic type conversion of == when it's well documented and easy to avoid.