Home >Backend Development >PHP Problem >PHP determines whether it is a number
PHP is_numeric Detects whether a variable is a number or a numeric string (Recommended learning: PHP Programming from Beginner to Master)
bool is_numeric ( mixed $var )
Returns TRUE if var is a number or numeric string, otherwise returns FALSE.
Recommended manual:php complete self-study manual
For example 1:
<?php $v = is_numeric ('58635272821786587286382824657568871098287278276543219876543') ? true : false; var_dump ($v); ?> The above script will output: bool(true)
Recommended related articles:
1.php determines whether a string is a number
2.How does php determine how many digits a number has?
3.php determines whether it is an integer
##Related video recommendations:1.
Dugu Jiujian (4)_PHP video tutorial
For example 2:
<?php $str="0"; $strTest=is_numeric(0); var_dump($strTest); ?> boolean true // function int_str($str){ if(is_numeric($str)){ $str = 'm'.$str; } return $str; }
The above is the detailed content of PHP determines whether it is a number. For more information, please follow other related articles on the PHP Chinese website!