I am trying to avoid a single quote inside my PHP by adding a slash in front of it. Unfortunately, I was not able to get it to work with str_replace, and I wonder if I am not doing something wrong.
I have the following ...
$string = 'I love Bob Pizza!'; $string = str_replace("'", "\\'", $string); echo $string;
When I use this, for some reason it does not replace the single quotation mark "\", as it should be.
Any help is much appreciated!
source share