3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function printer() { $status=true; while ($status) { $string = yield; echo $string; $status=false; } echo 'Generator is still working? ',($status == false)? 'false' : 'true'; return; } $printer = printer(); $printer->send('Hello world!'); echo $printer->current(); echo $printer->next(); ?>
Output for 5.5.24 - 7.1.0
Hello world!Generator is still working? false
Output for 5.0.0 - 5.4.45
Notice: Use of undefined constant yield - assumed 'yield' in /in/QsfhJ on line 5 yieldGenerator is still working? false Fatal error: Call to a member function send() on a non-object in /in/QsfhJ on line 14
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Notice: Use of undefined constant yield - assumed 'yield' in /in/QsfhJ on line 5 yieldGenerator is still working? false Fatal error: Call to a member function on a non-object in /in/QsfhJ on line 14
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant yield - assumed 'yield' in /in/QsfhJ on line 5 yieldGenerator is still working? false Fatal error: Call to a member function on a non-object in /in/QsfhJ on line 14