3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class IterateOver { static function string($str): Generator { for ($i = 0, $len = mb_strlen($str); $i < $len; ++$i) { yield mb_substr($str, $i, 1); } } } foreach (IterateOver::string("meh") as $char) { var_dump($char); } var_dump(IterateOver::string("meh"));
based on RJNEg
Output for 7.0.30 - 7.3.0beta1
string(1) "m" string(1) "e" string(1) "h" object(Generator)#2 (0) { }
Output for hhvm-3.18.5 - 3.22.0
string(1) "m" string(1) "e" string(1) "h" object(Generator)#1 (0) { }
Output for 5.6.30
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/CU4NR on line 6
Process exited with code 255.