PHP Zero integer is being evaluated as false -


as title says, php seems evaluating integer value 0 false.

take example snippet:

http://sandbox.onlinephpfunctions.com/code/13d885fb68359a3154999c2ef85db7c913c49bc5

<?php  if($exists = checkdup()){     echo $exits; } else{     echo "error!";   }  function checkdup ($foo = 'blah', $bar = 'blah'){     if ($foo == $bar) return (int) 0;     return false; } 

as can see, despite casting reply int php parsing return false in incorrect.

php evaluating lot false ;) example null, '', 0 have include type check well, can using === or !==

$exists = checkdup(); if($exists !== false){     echo $exits; } else{     echo "error!";   }  function checkdup ($foo = 'blah', $bar = 'blah'){     if ($foo == $bar) return 0;     return false; } 

Comments

Popular posts from this blog

'hasOwnProperty' in javascript -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -