3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function TestIterator(){ $tab = [1,2,3,4,5,6]; for($i = 0; $i < count($tab); $i++){ yield $tab[$i]; } } $r = TestIterator(); var_dump($r[0]);
based on LV59v
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Cannot use object of type Generator as array in /in/MVo7K:9 Stack trace: #0 {main} thrown in /in/MVo7K on line 9
Process exited with code 255.
Output for 5.5.24 - 5.6.28
Fatal error: Cannot use object of type Generator as array in /in/MVo7K on line 9
Process exited with code 255.
Output for 5.4.11 - 5.4.45
Parse error: syntax error, unexpected '$tab' (T_VARIABLE) in /in/MVo7K on line 5
Process exited with code 255.
Output for 5.3.21 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/MVo7K on line 3
Process exited with code 255.