PHP - is_numeric
Trieda
Metóda - is_numeric
(PHP 4, PHP 5, PHP 7)
Determines whether a given variable is a number. The number can also be represented by a string containing numeric value, but not in the hexadecimal or binary notations. The scientific notation (the "e" character) is supported.
Procedurálne
- function is_numeric (mixed $var) : bool
Parametre
| Názov | Dátový typ | Predvolená hodnota | Popis |
|---|---|---|---|
| $var | mixed | The variable being checked. |
Mávratovej hodnoty
Vracia: bool
Returns true if the variable is a number or a string containing
a numeric value, returns false otherwise.
Príklady
<?php
echo is_numeric("42") ? "'42' is a number.\n" : "'42' is not a number.\n";
echo is_numeric(42) ? "42 is a number.\n" : "42 is not a number.\n";
echo is_numeric("hi") ? "'hi is a number.\n" : "'hi is not a number.\n";
echo is_numeric(array()) ? "array() is a number.\n" : "array() is not a number.\n";
echo is_numeric(1212e2) ? "1212e2 is a number.\n" : "1212e2 is not a number.\n";
