3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // Normal Recusion function factorial1($num) { return $num === 0 ? 1 : $num * factorial1($num - 1); } // Tail Recusion function factorial2($num) { return factorialIter($num, 1); } // Tail Recusion Helper function factorialIter($num, $acc) { return $num === 0 ? $acc : factorialIter($num - 1, $acc * $num); } echo "<pre>"; $no = 100 ; echo factorial1($no), PHP_EOL; echo factorial2($no), PHP_EOL; ?>
Output for 4.3.10 - 4.4.9, 5.0.2 - 7.1.0
<pre>9.3326215443944E+157 9.3326215443944E+157
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.1
<pre>9.3326215443944E+157 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/0DWdR on line 20 PHP_EOL9.3326215443944E+157 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/0DWdR on line 21 PHP_EOL