3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $gen = function ($client, $stream) { while ($record = yield) { yield [ 'StreamName' => $stream, 'PartitionKey' => 'group' . rand(1, 5), 'Data' => $record, ]; } }; $records = $gen('things'); while ($records->valid()) { var_dump($records->current()); $records->next(); } $records->send('<Record Data>'); $records->send('<Record Data>'); while ($records->valid()) { var_dump($records->current()); $records->next(); } $records->send('<Record Data>'); $records->send('<Record Data>'); while ($records->valid()) { var_dump($records->current()); $records->next(); } $records->send('<Record Data>'); $records->send('<Record Data>'); $records->send('<Record Data>'); $records->send('<Record Data>'); $records->send('<Record Data>'); $records->send('<Record Data>'); while ($records->valid()) { var_dump($records->current()); $records->next(); }
Output for 7.1.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function {closure}(), 1 passed in /in/Oq2st on line 13 and exactly 2 expected in /in/Oq2st:3 Stack trace: #0 /in/Oq2st(13): {closure}('things') #1 {main} thrown in /in/Oq2st on line 3
Process exited with code 255.
Output for 5.5.0 - 5.6.28, 7.0.0 - 7.0.14
Warning: Missing argument 2 for {closure}() in /in/Oq2st on line 3 NULL
Output for hhvm-3.12.0 - 3.13.2
Fatal error: Uncaught Error: syntax error, unexpected T_YIELD in /in/Oq2st:4 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.10.0
Fatal error: syntax error, unexpected T_YIELD in /in/Oq2st on line 4
Process exited with code 255.
Output for 5.3.0 - 5.4.45
Parse error: syntax error, unexpected '[' in /in/Oq2st on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/Oq2st on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/Oq2st on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Oq2st on line 3
Process exited with code 255.