Query: is_numeric
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
IS_NUMERIC(3) 1 IS_NUMERIC(3) is_numeric - Finds whether a variable is a number or a numeric stringSYNOPSISbool is_numeric (mixed $var)DESCRIPTIONFinds 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.PARAMETERSo $var - The variable being evaluated.RETURN VALUESReturns TRUE if $var is a number or a numeric string, FALSE otherwise.EXAMPLESExample #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 ALSOctype_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)
Related Man Pages |
---|
apc_inc(3) - php |
isset(3) - php |
apc_dec(3) - php |
empty(3) - php |
is_float(3) - php |