Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.
isnum
Check if a variable is a number or a numeric string. This is much the same as (is_numeric) but will only return true for any number of digits with no decimal part and optional exponential part what so ever.

isnum

Quote

isnum ( mixed $value )


Parameters
value
The value to check

Return Values
This function will return true if the $value is a number of digits with no decimal part or optional exponential part what so ever and false on everything else.

Example 1
Code
<?php
$value = "abc123";
 
if (isnum($value)) {
 echo "This is a number of digits!";
} else {
 echo "This is not a number of digits!";
}
?>

Here we will check the string $value it it is a number of digits

Output to Example 1

Quote

This is not a number of digits!



Example 2
Code
<?php
$value = "123";
 
if (isnum($value)) {
 echo "This is a number of digits!";
} else {
 echo "This is not a number of digits!";
}
?>
Here we will check the string $value it it is a number of digits

Output to Example 2

Quote

This is a number of digits!


Example 3
Code
<?php
$value = "123.456";
 
if (isnum($value)) {
 echo "This is a number of digits!";
} else {
 echo "This is not a number of digits!";
}
?>
Here we will check the string $value it it is a number of digits

Output to Example 3

Quote

This is not a number of digits!


See also …


References

  • 1. ^ isnum by , retrieved 11/07/2014