❮ PHP Variable Handling Reference
Check whether a variable is a number or a numeric string, or not:
<?php
$a = 32;
echo "a is " . is_numeric($a) . "<br>";
$b = 0;
echo "b is " . is_numeric($b) . "<br>";
$c = 32.5;
echo "c is " . is_numeric($c) . "<br>";
$d = "32";
echo "d is " . is_numeric($d) . "<br>";
$e = true;
echo "e is " . is_numeric($e) . "<br>";
$f = null;
echo "f is " . is_numeric($f) . "<br>";
?>
Try it Yourself »
The is_numeric() function checks whether a variable is a number or a numeric string.
This function returns true (1) if the variable is a number or a numeric string, otherwise it returns false/nothing.
is_numeric(
variable);
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check |
Return Value: | TRUE if variable is a number or a numeric string, FALSE otherwise |
---|---|
Return Type: | Boolean |
PHP Version: | 4.0+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!