lundi 30 janvier 2017

Strange behaviour of an IF condition

$a = 101;

if (isset($a) && is_int($a) && in_array($a, range(1, 100))) {
  echo "TRUE";
} else echo "FALSE";

Why this condition returns FALSE as it should be while this IF:

if (isset($argv[1]) && is_int($argv[1]) && in_array($argv[1], range(1, 100))) {
  echo "TRUE";
} else echo "FALSE";

returns also FALSE where value passed as first parameter is 50 which is in range??? PHP-CLI is 7.0.9-TS-VC14-x64

Thanks in advance

Aucun commentaire:

Enregistrer un commentaire