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
Post a Comment