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; echo var_export($float, true) . " is numeric", PHP_EOL; } else { echo var_export($element, true) . " is NOT numeric", PHP_EOL; } }
Output for 7.1.0 - 7.3.0rc4
42 is numeric 42.0 is numeric 1337 is numeric 1337.0 is numeric 1337 is numeric 1337.0 is numeric 1337 is numeric 1337.0 is numeric 1337 is numeric 1337.0 is numeric 1337 is numeric 1337.0 is numeric 'not numeric' is NOT numeric array ( ) is NOT numeric 9 is numeric 9.1 is numeric NULL is NOT numeric
Output for 7.0.28
42 is numeric 42.0 is numeric 1337 is numeric 1337.0 is numeric 1337 is numeric 1337.0 is numeric 1337 is numeric 1337.0 is numeric 1337 is numeric 1337.0 is numeric 1337 is numeric 1337.0 is numeric 'not numeric' is NOT numeric array ( ) is NOT numeric 9 is numeric 9.0999999999999996 is numeric NULL is NOT numeric
Output for 5.6.1 - 5.6.38
42 is numeric 42 is numeric 1337 is numeric 1337 is numeric 1337 is numeric 1337 is numeric 1337 is numeric 1337 is numeric 1337 is numeric 1337 is numeric 1337 is numeric 1337 is numeric 'not numeric' is NOT numeric array ( ) is NOT numeric 9 is numeric 9.0999999999999996 is numeric NULL is NOT numeric