3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function a($value) { $frequency = (float) $value; return is_nan($frequency) ? null : $frequency; } function b($value) { $frequency = $value; return is_nan($frequency) ? null : (float) $frequency; } function meh($value) { var_dump(a($value) === b($value)); } foreach (array(0, NAN, "asdf", 2.4) as $value) { meh($value); }
based on 4F244
Output for 7.0.0 - 7.2.6
bool(true) bool(true) Warning: is_nan() expects parameter 1 to be float, string given in /in/pchku on line 10 bool(true) bool(true)
Output for 4.3.6 - 5.6.28
bool(true) bool(true) Warning: is_nan() expects parameter 1 to be double, string given in /in/pchku on line 10 bool(true) bool(true)
Output for 4.3.0 - 4.3.5
Notice: Use of undefined constant NAN - assumed 'NAN' in /in/pchku on line 17 bool(true) Warning: is_nan() expects parameter 1 to be double, string given in /in/pchku on line 10 bool(false) Warning: is_nan() expects parameter 1 to be double, string given in /in/pchku on line 10 bool(true) bool(true)