3v4l.org

run code in 300+ PHP versions simultaneously
<?php public function yieldAll(array $total) { if (!version_compare(phpversion(), '5.5.0', '>=') && !defined('HHVM_VERSION')) { throw new DomainException(__FUNCTION__.' works only with a PHP version that supports Generators'); } foreach ($total as $key => $value) { $stmt = (yield $key => $value); if (! $stmt) { return; } } } $toto = []; $res = yieldAll(['toto', 'tata', 'tutu']); foreach ($res as $key => $value) { if (1 == $key) { $res->send(false); } $toto[$key] = $value; } var_dump($toto);
Output for 5.4.0 - 5.4.26
Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /in/bbbIH on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_PUBLIC in /in/bbbIH on line 3
Process exited with code 255.

preferences:
181.74 ms | 1395 KiB | 63 Q