Last active
September 28, 2017 20:19
-
-
Save yphastos/137c00377f8029235387d214cf643444 to your computer and use it in GitHub Desktop.
false Cases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// false cases | |
$a = array(); | |
$s = ""; | |
$s0 = "0"; // en php es false (por representar un 0), pero en otros lenguajes puede variar, e.g. en javascript se castea como true (por ser cadena no vacia) | |
$i = 0; | |
$b = false; | |
$f = 0.0; | |
$h = 0x00; // el vardump la reporta como int | |
$n = null; | |
$aa = array($a,$s,$s0,$i,$b,$f,$h,$n,$x); // $x is undefined y genera notice | |
foreach($aa as $item){ | |
var_dump($item); // $x lo marca como NULL | |
$empty = empty($item); | |
var_dump($empty); // todos dan true, i.e. se consideran vacios. | |
echo "\n<br>--------\n<br>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment