Expression values

PHP type comparison tables

For example if $x=”"; what will empty($x) return? or is_null($x)? Or the even more surprising one: $x = “0″ will return TRUE on empty() even though it is considered a string.

2 Responses to “Expression values”

  1. Mark J Says:

    Very tricky stuff… don’t even get me started on the triple equals… if ($x === 1)

  2. michel Says:

    This is why empty() blows and why it should be avoided.
    (And why checking the data type is most usually a good idea if you need accurate results!)