3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function toFraction($number){ $numerator = $number < 0 ? -1 : 1; $denominator = 0; for(; $numerator < 1000; $numerator++){ $temp = $numerator / $number; if(ceil($temp) - $temp == 0){ $denominator = $temp; break; } } return ($denominator > 0) ? $numerator . '/' . $denominator : false; } echo toFraction( −0.0532994923858) . "\n" . toFraction( .5);
Output for 5.4.0 - 5.4.12
Parse error: syntax error, unexpected '.0532994923858' (T_DNUMBER) in /in/HkU5X on line 15
Process exited with code 255.
Output for 5.3.0 - 5.3.22
Parse error: syntax error, unexpected T_DNUMBER in /in/HkU5X on line 15
Process exited with code 255.