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.25 - 5.3.26, 5.4.16
Parse error: syntax error, unexpected '}' in /in/9C37F 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 SfkBY on line 39
Process exited with code 255.

preferences:
187.84 ms | 1395 KiB | 51 Q