Home > Article > Backend Development > 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:
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:
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!