addslashes — Quote string with slashes

by admin on February 13, 2010

string addslashes ( string $str )
Returns a string with backslashes before characters that need to be quoted in database queries etc. These characters are single quote (), double quote (), backslash (\) and NUL (the NULL byte).
Example:

<?php
$string = "My name is 'Jack Smit'";
// Outputs:
My name is \'Jack Smit\'
echo addslashes($string );
?>

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>