3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function echoFibonacciNumber(int $input) { if ($input < 0) { echo "Invalid input"; } if ($input === 0 || $input === 1) { $output = $input; } else { $fi = (sqrt(5) + 1) / 2; $output = floor(pow($fi, $input) / sqrt(5) + 1 / 2); } echo 'input: '.$input.', output: '.$output; } echo echoFibonacciNumber(6);
based on Ii0cH
Output for 7.0.0 - 7.3.0rc3
input: 6, output: 8
Output for 5.3.23 - 5.6.28
Catchable fatal error: Argument 1 passed to echoFibonacciNumber() must be an instance of int, integer given, called in /in/t24Fv on line 18 and defined in /in/t24Fv on line 3
Process exited with code 255.