3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function sed(string $re, string $sub): string { if (mb_strlen($re, "8bit") < 4 || $re[0] !== "s") throw new Error("Your syntax is invalid, go drown yourself"); [1 => $re, 2 => $rep, 3 => $mod] = preg_split("|(?<!\\\\){$re[1]}|", $re); $re = str_replace('@', '\@', $re); return preg_replace("@$re@$mod", $rep, $sub); } echo sed('s/Cat/Fox/i', 'Cat makes dog play guitar.'), PHP_EOL;
based on aFAh3
Output for 7.1.0 - 7.3.0beta1
Fox makes dog play guitar.
Output for 7.0.0 - 7.0.25
Parse error: syntax error, unexpected '=' in /in/o9Hiq on line 8
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: syntax error, unexpected '=' in /in/o9Hiq:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: syntax error, unexpected '=' in /in/o9Hiq:8 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting '{' in /in/o9Hiq on line 3
Process exited with code 255.