3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $searchTerm = "abcd"; $replaceTerm = "XXXX"; $test=array("$searchTerm/$searchTerm_.mp3", "$searchTerm", "xay$searchTerm", "asdasd/$searchTerm.mp3", "$searchTerm.", "blahahbasd$searchTerm"); foreach ($test as $t) echo "$t => " . preg_replace("/(". preg_quote($searchTerm) . "([^_.])|". preg_quote($searchTerm) . "$)/x", preg_quote($replaceTerm) . "\${2}", $t) . "\n";
Output for 5.0.4 - 7.1.0
Notice: Undefined variable: searchTerm_ in /in/fR8oX on line 5 abcd/.mp3 => XXXX/.mp3 abcd => XXXX xayabcd => xayXXXX asdasd/abcd.mp3 => asdasd/abcd.mp3 abcd. => abcd. blahahbasdabcd => blahahbasdXXXX
Output for 4.3.0 - 5.0.3
Notice: Undefined variable: searchTerm_ in /in/fR8oX on line 5 abcd/.mp3 => XXXX/.mp3 abcd => XXXX xayabcd => xayXXXX asdasd/abcd.mp3 => asdasd/abcd.mp3 abcd. => abcd. blahahbasdabcd => blahahbasdXXXX