3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Foo { public $bar = 'A'; public function doSomething() { $this->bar = 'B'; yield; } } $foo = new Foo(); echo $foo->bar . PHP_EOL; $it = $foo->doSomething(); echo $foo->bar . PHP_EOL; foreach ($it as $t) { } echo $foo->bar . PHP_EOL;
based on XaIk5
Output for 5.5.24 - 7.1.0
A A B
Output for 5.0.2 - 5.4.45
A Notice: Use of undefined constant yield - assumed 'yield' in /in/u59JZ on line 10 B Warning: Invalid argument supplied for foreach() in /in/u59JZ on line 18 B
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u59JZ on line 15 APHP_EOL Notice: Use of undefined constant yield - assumed 'yield' in /in/u59JZ on line 10 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u59JZ on line 17 BPHP_EOL Warning: Invalid argument supplied for foreach() in /in/u59JZ on line 18 Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/u59JZ on line 21 BPHP_EOL
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/u59JZ on line 5
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 T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/u59JZ on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/u59JZ on line 5
Process exited with code 255.