PHP uses is_numeric instance parsing

coldplay.xixi
Release: 2023-04-08 20:08:01
forward
2637 people have browsed it

PHP uses is_numeric instance parsing

PHP is_numeric

function is used to detect whether a variable is a number or a numeric string.

Syntax

is_numeric (mixed $var)

Return value

Returns TRUE if the specified variable is a number and a numeric string, otherwise returns FALSE .

Example

$var_name1 = 678;
$var_name2 = "a678";
$var_name3 = "678";
$var_name4 = "runoob.com";
$var_name5 = 698.99;
$var_name6 = array("a1", "a2");
$var_name7 = +125689.66;
$var_name8 = -125689.66;
 
if(is_numeric($var_name1)) echo '$var_name1 true';
if(is_numeric($var_name2)) echo '$var_name2 true';
if(is_numeric($var_name3)) echo '$var_name3 true';
if(is_numeric($var_name4)) echo '$var_name4 true';
if(is_numeric($var_name5)) echo '$var_name5 true';
if(is_numeric($var_name6)) echo '$var_name6 true';
if(is_numeric($var_name7)) echo '$var_name7 true';
if(is_numeric($var_name8)) echo '$var_name8 true';
//输出:$var_name1 true$var_name3 true$var_name5 true$var_name7 true$var_name8 true
Copy after login

It can be seen from the above example that returning 1, 3, 5, 7, and 8 all returns true, indicating that others return false

Recommended tutorial: " PHP video tutorial

The above is the detailed content of PHP uses is_numeric instance parsing. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:liqingbo.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!