3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class štring { static function kek($str): Generator { for ($i = 0, $len = mb_strlen($str); $i < $len; ++$i) { yield mb_substr($str, $i, 1); } } } foreach (štring::kek("meh") as $char) { var_dump($char); } var_dump(štring::kek("meh"));
based on 2CFsY
Output for 7.0.30 - 7.3.0rc3
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/RJNEg on line 6
Process exited with code 255.