3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = [1,2,3,4]; function x($input) { foreach ($input as $value) { yield $value; } return count($value); } foreach (x($a) as $value) { echo $value; }
Output for 7.2.0 - 7.2.8
1234 Warning: count(): Parameter must be an array or an object that implements Countable in /in/Z3e1U on line 9
Output for 7.0.0 - 7.1.20
1234
Output for 5.5.24 - 5.6.28
Fatal error: Generators cannot return values using "return" in /in/Z3e1U on line 9
Process exited with code 255.
Output for 5.4.10 - 5.4.45
Parse error: syntax error, unexpected '$value' (T_VARIABLE) in /in/Z3e1U on line 7
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Z3e1U on line 3
Process exited with code 255.