I'm trying to escape a single quote within my PHP by adding a slash before it. Unfortunately, I've been unable to get it working with str_replace and I'm wondering if I'm doing something wrong.
What I have is the following ...
$string = 'I love Bob's Pizza!';
$string = str_replace("'", "\\'", $string);
echo $string;
When I use this, for some reason it's not replacing the single quote with "\'" as it should.
Any help is greatly appreciated!