How to Escape Quotes in PHP
- 1). Right-click the PHP file you want to edit and select "Open With." Click the PHP file editor you want to use to change the code.
- 2). Locate the string that contains the quotes. The following code shows you how to create a PHP string, if you do not already have one defined:
$var = 'this string with a quote "'; - 3). Add the "addslashes" function to the string. The following code shows you how to add the escape backslash character in front of the quotes:
$var = addslashes($var);
Source...