addslashes

string addslashes(string string) 

Escapes all backslashes, null bytes, and single or double quotes in a given string.

Returns:

String with special characters escaped

Description:

addslashes() is usually used to prepare a string for storage in a database or some kind of delimited format such as comma-separated values (CSV). The function places a single backslash in front of any backslashes (\), quotes (" or '') or null (\0) bytes in the string argument. This prevents the contents of the string from accidentally “breaking” the quoting of whatever format the string is being stored in. See the first example for a practical demonstration of how this can happen.

Version:

PHP 3+, PHP 4+

See also:

To escape or unescape strings:

 addcslashes() ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.