3v4l.org

run code in 300+ PHP versions simultaneously
<?php <?php /** * Ask santa for less fugly code next year * * Happy new year from Ignas:) */ //Open alternate window fwrite(STDOUT, "\0337\033[?47h"); $top = " | \\ ' / "; $base = " >*< >O<@< >>>@<<* >@>*<O<<< >*>>@<<<@<< >@>>O<<<*<<@< >*>>O<<@<<<@<<< >@>>*<<@<>*<<O<*< >O>>*<<@<>O><<*<@<< >*>>@><O<<*>>@><*<O<< >@>>O<*<O>>@<<O<<<*<@<< >O>>*<<@>O><*<O><@<<<O<*< | | | | /___\ "; /** * Add sparkling top * * @param $top * @param int $size * @return string */ function sparkleTop($top, $size = 1) { $topLight = '- (@) -'; $topLight = str_repeat(' ', 5 - $size) . preg_replace('/-{1,}/', str_repeat('-', $size), $topLight); $top = $top . $topLight; return $top; } /** * Switch toys to add animation * * @param $tree * @param bool|false $reverse * @return string */ function switchToys($tree, $reverse = false) { $replace = ["*" => "@", "@" => "*"]; if ($reverse) { $replace = array_flip($replace); } $tree = strtr($tree, $replace); return $tree; } /** * Color text * * @param $text * @param $color * @return string */ function color($text, $color) { $colors = [ 'red' => "\033[31m", 'green' => "\033[32m", 'yellow' => "\033[33m" ]; $end = "\033[0m"; $text = $colors[$color] . $text . $end; return $text; } // color all <> symbols green $base = str_replace( ['<', '>'], [ color('<', 'green'), color('>', 'green') ], $base ); $reverse = true; $iteration = 0; // animate it all while (true) { $reverse = !$reverse; // clear screen fwrite(STDOUT, "\033[H\033[2J"); $output = $base; if ($iteration % 3 === 0) { $base = switchToys($base, $reverse); $iteration = 0; } // color toys $output = str_replace('*', color('*', 'red'), $base); $output = str_replace('@', color('@', 'yellow'), $output); $topping = sparkleTop($top, $iteration); $output = $topping . $output; $iteration++; echo $output; usleep(500000); } ?>
Output for 7.0.0 - 7.0.1
Parse error: syntax error, unexpected '<', expecting end of file in /in/fSC6C on line 3
Process exited with code 255.
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
Parse error: syntax error, unexpected '<' in /in/fSC6C on line 3
Process exited with code 255.

preferences:
169.36 ms | 1395 KiB | 25 Q