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.0 - 5.3.26, 5.4.0 - 5.4.16
Parse error: syntax error, unexpected '{' in /in/GuqPl on line 9
Process exited with code 255.

preferences:
190.01 ms | 1395 KiB | 51 Q