Add backslashes to the predefined characters in a string in PHP
Description
The following code shows how to add backslashes to the predefined characters in a string.
Example
/* ww w.j a v a2s . c o m*/
<?php
$str = "What's XML?";
echo $str . " This is not safe in a database query.<br>";
echo addslashes($str) . " This is safe in a database query.";
?>
The code above generates the following result.