3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FunctionalFun { public function __construct() { $each = function(array $collection, callable $fn) { $coll = $collection; if (is_array($coll)) { $length = count($coll); } elseif (is_object($coll)) { $length = count(get_object_vars($coll)); } else { throw new Exception('Not iterable.'); } $iteration = function($c, $f) { if (!$called) { $called = 0; } if ($iteration->called >= $length) { return; } call_user_func($fn, $coll[$iteration->called++]); $iteration($c, $f); $iteration->called = $iteration->called; } } } } $test = new FunctionalFun();
Output for 5.3.26, 5.4.16
Parse error: syntax error, unexpected '}' in /in/3Zpsa on line 39
Process exited with code 255.
Output for 5.3.0 - 5.3.24, 5.4.0 - 5.4.15
Parse error: syntax error, unexpected '}' in 9jcqB on line 39
Process exited with code 255.
Output for 5.3.25
Parse error: syntax error, unexpected '}' in /in/9jcqB on line 39
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in 9jcqB on line 6
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in 9jcqB on line 6
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in 9jcqB on line 4
Process exited with code 255.
Output for 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in 9jcqB on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in 9jcqB on line 4
Process exited with code 255.
Output for 4.3.0
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/9jcqB on line 4
Process exited with code 255.

preferences:
207.72 ms | 1386 KiB | 104 Q