3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function test() { $data = yield; //echo $data; $foo = foo(); $foo->send($data . ' je kokot'); } function foo() { $data = yield; echo $data; } $d = test(); var_dump($d); $d->send("Lukas"); $d->send("Milan");
Output for 5.5.0 - 5.6.28, 7.0.0 - 7.1.0
object(Generator)#1 (0) { } Lukas je kokot
Output for hhvm-3.12.0 - 3.13.2
object(Generator)#1 (0) { } Lukas je kokot Fatal error: Uncaught exception 'Exception' with message 'Generator is already finished' in /in/a8D1L:28 Stack trace: #0 /in/a8D1L(28): Generator->send() #1 {main}
Process exited with code 255.
Output for hhvm-3.10.0
object(Generator)#1 (0) { } Fatal error: Uncaught exception 'Exception' with message 'Need to call next() first' in /in/a8D1L:27 Stack trace: #0 /in/a8D1L(27): 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/a8D1L on line 5 Notice: Use of undefined constant yield - assumed 'yield' in /in/a8D1L on line 16 yield Fatal error: Call to a member function send() on a non-object in /in/a8D1L on line 11
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Notice: Use of undefined constant yield - assumed 'yield' in /in/a8D1L on line 5 Notice: Use of undefined constant yield - assumed 'yield' in /in/a8D1L on line 16 yield Fatal error: Call to a member function on a non-object in /in/a8D1L on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant yield - assumed 'yield' in /in/a8D1L on line 5 Notice: Use of undefined constant yield - assumed 'yield' in /in/a8D1L on line 16 yield Fatal error: Call to a member function on a non-object in /in/a8D1L on line 11