- Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.26
- Parse error: syntax error, unexpected '{' in /in/Ced2C on line 7
Process exited with code 255.
<?php
function grep($pattern)
{
echo "Looking for $pattern\n";
while (true) {
$line = (yield);
if (false !== strpos($line, $pattern) {
echo "$line\n";
}
}
}
// Imagine we parsed a file which returned the following lines.
$lines = array(
"<?php\n",
"echo 'toto';",
);
$g = grep('php');
foreach ($lines as $line) {
$g->send($line);
}