3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Factoriel {public function calculate() { if(func_num_args() != 1) throw new Exception ("Invalid arguments count for method calculate!"); if(($n = (int)func_get_arg(0)) <= 0) throw new Exception ("Invalid argument supplied for method calculate!"); $result = 1; foreach(range(1, $n) as $current) $result = $this->multiply ($result, $current); return $result;}private function multiply($left, $right) { return bcmul("$left", "$right"); }}$factoriel = new Factoriel();echo $factoriel->calculate(a);?>
based on OdQWQ
Output for 7.2.0
Warning: Use of undefined constant a - assumed 'a' (this will throw an Error in a future version of PHP) in /in/NqTVe on line 1 Fatal error: Uncaught Exception: Invalid argument supplied for method calculate! in /in/NqTVe:1 Stack trace: #0 /in/NqTVe(1): Factoriel->calculate('a') #1 {main} thrown in /in/NqTVe on line 1
Process exited with code 255.
Output for 7.0.0 - 7.1.10
Notice: Use of undefined constant a - assumed 'a' in /in/NqTVe on line 1 Fatal error: Uncaught Exception: Invalid argument supplied for method calculate! in /in/NqTVe:1 Stack trace: #0 /in/NqTVe(1): Factoriel->calculate('a') #1 {main} thrown in /in/NqTVe on line 1
Process exited with code 255.
Output for 5.5.0 - 5.6.28
Notice: Use of undefined constant a - assumed 'a' in /in/NqTVe on line 1 Fatal error: Uncaught exception 'Exception' with message 'Invalid argument supplied for method calculate!' in /in/NqTVe:1 Stack trace: #0 /in/NqTVe(1): Factoriel->calculate('a') #1 {main} thrown in /in/NqTVe on line 1
Process exited with code 255.