3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function setArgs(Generator $args) { $value = $args->send(1); var_dump("got back $value"); } function genArgs() { var_dump("received ".yield); } $g = genArgs(); setArgs($g);
based on BLh7a
Output for 5.5.24 - 7.2.0
string(10) "received 1" string(9) "got back "
Output for 5.2.0 - 5.4.45
Notice: Use of undefined constant yield - assumed 'yield' in /in/cCDtX on line 9 string(14) "received yield" Catchable fatal error: Argument 1 passed to setArgs() must be an instance of Generator, null given, called in /in/cCDtX on line 13 and defined in /in/cCDtX on line 3
Process exited with code 255.
Output for 5.1.0 - 5.1.6
Notice: Use of undefined constant yield - assumed 'yield' in /in/cCDtX on line 9 string(14) "received yield" Fatal error: Argument 1 passed to setArgs() must not be null, called in /in/cCDtX on line 13 and defined in /in/cCDtX on line 3
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Notice: Use of undefined constant yield - assumed 'yield' in /in/cCDtX on line 9 string(14) "received yield" Fatal error: Argument 1 must not be null in /in/cCDtX on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting ')' in /in/cCDtX on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting ')' in /in/cCDtX on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/cCDtX on line 3
Process exited with code 255.