Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • Okay, how about an E_NOTICE then? :) Commented Dec 7, 2010 at 21:10
  • @Stephen E_NOTICE might be ok, but to me the ambiguous state is concerning - how would you know by looking at one bit of code if the variable was in that state (having been cast somewhere else)? Also, I found another condition and added it to my answer. Commented Dec 8, 2010 at 7:06
  • 1
    As for Boolean evaluation, PHP docs clearly state what is considered to be false when evaluating to boolean and both empty string and a string "0" are considered false. So even when this feels bizare, it is normal and expected behaviour. Commented Jan 5, 2011 at 22:48
  • to add bit to confusion: echo "010" == 010 and echo "0x10" == 0x10 ;-) Commented Mar 25, 2013 at 15:00
  • 1
    Note that as of PHP 7, this answer's notes on scalar type hinting are inaccurate. Commented Jun 4, 2017 at 8:35