3v4l.org

run code in 300+ PHP versions simultaneously
<?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); }
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.

preferences:
184.16 ms | 1395 KiB | 63 Q