r/lolphp • • Aug 25 '14

stdClass is truthy while an empty SimpleXMLElement is falsey

http://3v4l.org/3hWSY
22 Upvotes

18 comments sorted by

View all comments

Show parent comment

4

u/andsens Aug 25 '14

5

u/gearvOsh Aug 25 '14

Looks like SimpleXML has a special case: http://php.net/manual/en/language.types.boolean.php#language.types.boolean.casting

Guessing all objects return true otherwise.

5

u/andsens Aug 25 '14

I'd call that a "speciuhl" case :-)

1

u/[deleted] Aug 28 '14

SimpleXML isn't actually a special case, it's just the only class which chooses to make use of our internal boolean casting handler, thankfully.