addslashes(): escapes quotes, double quotes, backslashes, and NULLs with backslashes : String Escape « String « PHP






addslashes(): escapes quotes, double quotes, backslashes, and NULLs with backslashes

 

<?php
$escapedstring = addslashes("He said, 'I'm a dog.'");
$query = "INSERT INTO test (quote) values ('$escapedstring')";

echo($query);
?>



           
       








Related examples in the same category

1.To embed a single quote in a singly quoted string, escape it with a backslash
2.quotemeta(): escapes \ + * ? [ ^ ] ( $ )
3.String SQL command escape