3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $tests = array( "42", 1337, 0x539, 02471, 0b10100111001, 1337e0, "not numeric", array(), 9.1, null ); foreach ($tests as $element) { if (\is_numeric($element)) { $int = (int) $element; echo var_export($int, true) . " is numeric", PHP_EOL; $float = (float) ($element * 10); echo var_export($float, true) . " is numeric", PHP_EOL; } else { echo var_export($element, true) . " is NOT numeric", PHP_EOL; } }
Output for 7.3.0rc3
42 is numeric 420.0 is numeric 1337 is numeric 13370.0 is numeric 1337 is numeric 13370.0 is numeric 1337 is numeric 13370.0 is numeric 1337 is numeric 13370.0 is numeric 1337 is numeric 13370.0 is numeric 'not numeric' is NOT numeric array ( ) is NOT numeric 9 is numeric 91.0 is numeric NULL is NOT numeric