3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function rev($str) { if ( ! $str ) { return; } return rev(substr($str,1)) . $str{0}; } function sum($arr) { if ( empty($arr) ) { return array(); } return $arr[0] + sum(array_shift($arr)); } $a = array(5,4,7,8,9,3); echo sum($a); echo rev('hola mundos ninos');
Output for 7.0.0 - 7.1.0
Warning: array_shift() expects parameter 1 to be array, integer given in /in/dKgdS on line 13 Fatal error: Uncaught Error: Unsupported operand types in /in/dKgdS:13 Stack trace: #0 /in/dKgdS(13): sum(5) #1 /in/dKgdS(17): sum(Array) #2 {main} thrown in /in/dKgdS on line 13
Process exited with code 255.
Output for 5.3.0 - 5.6.28
Warning: array_shift() expects parameter 1 to be array, integer given in /in/dKgdS on line 13 Fatal error: Unsupported operand types in /in/dKgdS on line 13
Process exited with code 255.
Output for 4.3.2 - 5.2.17
Warning: array_shift(): The argument should be an array in /in/dKgdS on line 13 Fatal error: Unsupported operand types in /in/dKgdS on line 13
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Warning: array_shift() [http://www.php.net/function.array-shift]: The argument should be an array in /in/dKgdS on line 13 Fatal error: Unsupported operand types in /in/dKgdS on line 13