Skip to content

Instantly share code, notes, and snippets.

@yphastos
Last active September 28, 2017 20:19
Show Gist options
  • Save yphastos/137c00377f8029235387d214cf643444 to your computer and use it in GitHub Desktop.
Save yphastos/137c00377f8029235387d214cf643444 to your computer and use it in GitHub Desktop.
false Cases
// 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