3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function castToNumber($genericStringNumber) { return $genericStringNumber+0; } //$yourNumberCasted = castToNumber($yourStringNumber); function castNumber($n) { if(!is_numeric($n)) return 0; return (is_float($n)) ? (float) $n : (int) $n; } //$casted = castNumber($num_to_cast); function get_numeric($val) { if (is_numeric($val)) { return $val + 0; } return 0; } var_dump(is_numeric('12.z'));
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
bool(false)