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

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -