Unix and Linux Discussions Tagged with numeric |
|
Thread / Thread Starter |
Last Post |
Replies |
Views |
Forum |
|
|
|
3 |
2,648 |
UNIX for Beginners Questions & Answers |
|
|
|
7 |
2,348 |
Shell Programming and Scripting |
|
|
|
4 |
2,781 |
UNIX for Advanced & Expert Users |
|
|
|
4 |
3,049 |
Shell Programming and Scripting |
|
|
|
2 |
4,361 |
Shell Programming and Scripting |
|
|
|
2 |
10,139 |
Shell Programming and Scripting |
|
|
|
5 |
58,782 |
UNIX for Advanced & Expert Users |
|
|
|
3 |
4,344 |
Shell Programming and Scripting |
|
|
|
4 |
16,515 |
Shell Programming and Scripting |
|
|
|
2 |
4,384 |
Shell Programming and Scripting |
|
|
|
7 |
10,435 |
UNIX for Dummies Questions & Answers |
|
|
|
3 |
3,359 |
Shell Programming and Scripting |
|
|
|
1 |
2,625 |
Shell Programming and Scripting |
|
|
|
2 |
2,915 |
Shell Programming and Scripting |
|
|
|
7 |
5,315 |
Shell Programming and Scripting |
|
|
|
10 |
3,964 |
Shell Programming and Scripting |
|
|
|
5 |
14,144 |
Solaris |
|
|
|
3 |
7,072 |
Shell Programming and Scripting |
|
|
|
7 |
8,329 |
Shell Programming and Scripting |
|
|
|
3 |
7,889 |
Shell Programming and Scripting |
|
|
|
2 |
7,491 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
12,935 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
5,224 |
UNIX for Dummies Questions & Answers |
|
|
|
4 |
5,832 |
UNIX for Dummies Questions & Answers |
|
|
|
1 |
4,021 |
UNIX for Dummies Questions & Answers |
|
|
|
2 |
5,353 |
UNIX for Dummies Questions & Answers |
IS_NUMERIC(3) 1 IS_NUMERIC(3)
is_numeric - Finds whether a variable is a number or a numeric string
SYNOPSIS
bool is_numeric (mixed $var)
DESCRIPTION
Finds whether the given variable is numeric. Numeric strings consist of optional sign, any number of digits, optional decimal part and
optional exponential part. Thus +0123.45e6 is a valid numeric value. Hexadecimal (e.g. 0xf4c3b00c), Binary (e.g. 0b10100111001), Octal
(e.g. 0777) notation is allowed too but only without sign, decimal and exponential part.
PARAMETERS
o $var
- The variable being evaluated.
RETURN VALUES
Returns TRUE if $var is a number or a numeric string, FALSE otherwise.
EXAMPLES
Example #1
is_numeric(3) examples
<?php
$tests = array(
"42",
1337,
0x539,
02471,
0b10100111001,
1337e0,
"not numeric",
array(),
9.1
);
foreach ($tests as $element) {
if (is_numeric($element)) {
echo "'{$element}' is numeric", PHP_EOL;
} else {
echo "'{$element}' is NOT numeric", PHP_EOL;
}
}
?>
The above example will output:
SEE ALSO
ctype_digit(3), is_bool(3), is_null(3), is_float(3), is_int(3), is_string(3), is_object(3), is_array(3).
PHP Documentation Group IS_NUMERIC(3)