3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a="a / b"; $a=preg_replace('/\//','\\',$a); echo "First version: {$a}\n"; $a=preg_replace('/\//','\\\\',$a); echo "Second version: {$a}\n"; ?>
Output for 5.6.0 - 5.6.25, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.26, 7.4.0 - 7.4.14, 8.0.0
First version: a \ b Second version: a \ b