3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function routeIterator(&$path) { while (!empty($path)) { yield $path[0]; array_shift($path); } } function exampleGenerator($path) { foreach ($routeIterator($path) as $chunk) { yield "Chunk: " . $chunk; echo " Sent value: " . yield . "\n"; } } foreach (exampleGenerator([1,2,3,4,5]) as $signal) { echo $signal; }
Output for 7.0.0 - 7.2.0
Notice: Undefined variable: routeIterator in /in/R6uop on line 11 Fatal error: Uncaught Error: Function name must be a string in /in/R6uop:11 Stack trace: #0 /in/R6uop(17): exampleGenerator(Array) #1 {main} thrown in /in/R6uop on line 11
Process exited with code 255.
Output for 5.5.24 - 5.6.21
Notice: Undefined variable: routeIterator in /in/R6uop on line 11 Fatal error: Function name must be a string in /in/R6uop on line 11
Process exited with code 255.
Output for 5.4.12 - 5.4.45
Parse error: syntax error, unexpected '$path' (T_VARIABLE) in /in/R6uop on line 5
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/R6uop on line 5
Process exited with code 255.