PHP/Reflection/is numeric

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

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

 
<?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";
?>



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

 
<?php
     $item = 43;
     echo "\$item is of type array: ".is_array($item)."<br />";
     echo "\$item is of type integer: ".is_integer($item)."<br />";
     echo "\$item is numeric: ".is_numeric($item)."<br />";
?>