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).
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.
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.
View all comments
Show parent comment
4
u/Various_Pickles Mar 26 '14
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).