3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function test() { $n = 1; //while (true) { $x = yield; echo $x; echo $n; $n++; $x = yield; echo $x; echo $n; $n++; $x = yield; echo $x; echo $n; $n++; //} } $test = test(); $test->send('A'); $test->send('B'); $test->send('C');
based on riUgO
Output for 5.5.24 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
A1B2C3
Output for hhvm-3.10.0
Fatal error: Uncaught exception 'Exception' with message 'Need to call next() first' in /in/WeL9K:25 Stack trace: #0 /in/WeL9K(25): Generator->send() #1 {main}
Process exited with code 255.
Output for 5.0.0 - 5.4.45
Notice: Use of undefined constant yield - assumed 'yield' in /in/WeL9K on line 7 yield1 Notice: Use of undefined constant yield - assumed 'yield' in /in/WeL9K on line 12 yield2 Notice: Use of undefined constant yield - assumed 'yield' in /in/WeL9K on line 17 yield3 Fatal error: Call to a member function send() on a non-object in /in/WeL9K on line 25
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Notice: Use of undefined constant yield - assumed 'yield' in /in/WeL9K on line 7 yield1 Notice: Use of undefined constant yield - assumed 'yield' in /in/WeL9K on line 12 yield2 Notice: Use of undefined constant yield - assumed 'yield' in /in/WeL9K on line 17 yield3 Fatal error: Call to a member function on a non-object in /in/WeL9K on line 25
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant yield - assumed 'yield' in /in/WeL9K on line 7 yield1 Notice: Use of undefined constant yield - assumed 'yield' in /in/WeL9K on line 12 yield2 Notice: Use of undefined constant yield - assumed 'yield' in /in/WeL9K on line 17 yield3 Fatal error: Call to a member function on a non-object in /in/WeL9K on line 25