3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function gen() { var_dump(yield +1); var_dump(yield -1); var_dump(yield * -1); // other ops still should behave normally } for ($gen = gen(); $gen->valid(); $gen->send(1)) { echo "\n"; var_dump($gen->current()); }
Output for 5.5.24 - 7.3.0rc4
int(1) int(1) int(-1) int(1) NULL int(-1)
Output for 5.0.0 - 5.4.45
Notice: Use of undefined constant yield - assumed 'yield' in /in/dTl8K on line 3 int(1) Notice: Use of undefined constant yield - assumed 'yield' in /in/dTl8K on line 4 int(-1) Notice: Use of undefined constant yield - assumed 'yield' in /in/dTl8K on line 5 int(0) Fatal error: Call to a member function valid() on a non-object in /in/dTl8K on line 7
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Notice: Use of undefined constant yield - assumed 'yield' in /in/dTl8K on line 3 int(1) Notice: Use of undefined constant yield - assumed 'yield' in /in/dTl8K on line 4 int(-1) Notice: Use of undefined constant yield - assumed 'yield' in /in/dTl8K on line 5 int(0) Fatal error: Call to a member function on a non-object in /in/dTl8K on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant yield - assumed 'yield' in /in/dTl8K on line 3 int(1) Notice: Use of undefined constant yield - assumed 'yield' in /in/dTl8K on line 4 int(-1) Notice: Use of undefined constant yield - assumed 'yield' in /in/dTl8K on line 5 int(0) Fatal error: Call to a member function on a non-object in /in/dTl8K on line 7