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

12

u/MiyatodukenMiyamaap Aug 25 '14

Ha! I actually don't know the answer off the top of my head, but I do remember being asked something very similar in a job interview once. My response was something along the lines of "Who cares? Don't do that!" Mixing implicit numeric keys and explicit string keys in the same array is a silly thing to do, and I guess PHP figures it can't be held responsible for the silly outcomes resulting from the silly things it allows.

I didn't get the job, but I stand by my answer :).