PHP/Reflection/is numeric

Материал из Web эксперт
Перейти к: навигация, поиск

function is_numeric() checks if the value passed as the argument is numeric

   <source lang="html4strict">

<?php $a = 1; echo "is_numeric($a) = " . (is_numeric($a) ? "true" : "false") . "\n"; $a = 1.5; echo "is_numeric($a) = " . (is_numeric($a) ? "true" : "false") . "\n"; $a = true; echo "is_numeric($a) = " . (is_numeric($a) ? "true" : "false") . "\n"; $a = "Test"; echo "is_numeric($a) = " . (is_numeric($a) ? "true" : "false") . "\n"; $a = "3.5"; echo "is_numeric($a) = " . (is_numeric($a) ? "true" : "false") . "\n"; $a = "3.5E27"; echo "is_numeric($a) = " . (is_numeric($a) ? "true" : "false") . "\n"; $a = 0x19; echo "is_numeric($a) = " . (is_numeric($a) ? "true" : "false") . "\n"; $a = 0777; echo "is_numeric($a) = " . (is_numeric($a) ? "true" : "false") . "\n"; ?>

 </source>
   
  


is it an array, or is it an integer, or is it numeric

   <source lang="html4strict">

<?php

    $item = 43;
    echo "\$item is of type array: ".is_array($item)."
"; echo "\$item is of type integer: ".is_integer($item)."
"; echo "\$item is numeric: ".is_numeric($item)."
";

?>

 </source>