Consider the below php code:


$foo = <value from an HTTP param>;

if ($foo) {//make sure this parameter is set

  //do your operations

}

You are in for a rude shock if your HTTP parameter has a value 0. PHP evaluates a string 0 as boolean false.

Edit: I was going through some PHP internals and happened to land on this function which evaluates boolean – http://lxr.php.net/xref/PHP_5_4/Zend/zend_operators.c#501. You can see the check being made for string zero here.

Advertisements