3v4l.org

run code in 300+ PHP versions simultaneously
<?php function foo() { $foo = (yield 'strlen' => ['a']); $foo .= (yield 'strlen' => ['ab']); $foo .= (yield 'strlen' => ['abc']); yield $foo."final"; } function call_generator_function($g) { $args = $g->current(); $callable = $g->key(); while ($g->valid() && is_callable($callable)) { $return = call_user_func_array($callable, $args); $g->send($return); $args = $g->current(); $callable = $g->key(); } return $args; } $result = call_generator_function(foo()); var_dump($result); var_dump((yield 'strlen' => ['a'])));
Output for 5.4.0 - 5.4.34
Parse error: syntax error, unexpected ''strlen'' (T_CONSTANT_ENCAPSED_STRING) in /in/oioRe on line 5
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /in/oioRe on line 5
Process exited with code 255.

preferences:
186.06 ms | 1395 KiB | 71 Q