3v4l.org

run code in 300+ PHP versions simultaneously
<?php class a { public function foreach($a, callable $c) { foreach ($a as $k=>$v) { $r[] = $c($k, $v, $a); } } } function foreach($a, callable $c) { foreach ($a as $k=>$v) { $r[] = $c($k, $v, $a); } }
Output for 7.0.5 - 7.0.6
Parse error: syntax error, unexpected 'foreach' (T_FOREACH), expecting '(' in /in/bpYuE on line 11
Process exited with code 255.
Output for 7.0.0 - 7.0.4
Parse error: syntax error, unexpected 'foreach' (T_FOREACH), expecting identifier (T_STRING) or '(' in /in/bpYuE on line 11
Process exited with code 255.
Output for 5.5.0 - 5.5.35, 5.6.0 - 5.6.21
Parse error: syntax error, unexpected 'foreach' (T_FOREACH), expecting identifier (T_STRING) in /in/bpYuE on line 4
Process exited with code 255.

preferences:
171.9 ms | 1006 KiB | 7 Q