3v4l.org

run code in 300+ PHP versions simultaneously
<?php function sphinxesc($x){ $depth = 0; for ($i = 0; $i < strlen($x); ++$i){ $depth += $x[$i] == '(' ? 1 : 0; $depth -= $x[$i] == ')' ? 1 : 0; } if($depth != 0) $x = str_replace(array('(',')'),' ',$x); $x = str_replace(array('/','~','@'), ' ',$x); $x = preg_replace('/[\!\-\^]+(?!\w)/', ' ',$x); return $x } echo sphinxesc('hi! this is shit!');
Output for 7.0.0 - 7.0.1
Parse error: syntax error, unexpected '}', expecting ';' in /in/RNW9J on line 15
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/RNW9J on line 15
Process exited with code 255.

preferences:
164.64 ms | 1395 KiB | 25 Q