PHP addslashes() Function
Example
Add a backslash in front of each double quote ("):
<?php
$str = addslashes('What does "yolo" mean?');
echo($str);
?>
Try it Yourself »
Definition and Usage
The addslashes() function returns a string with backslashes in front of predefined characters.
The predefined characters are:
- single quote (')
- double quote (")
- backslash (\)
- NULL
Syntax
addslashes(string)
Parameter Values
| Parameter | Description |
|---|---|
| string | Required. Specifies the string to be escaped |
Technical Details
| Return Value: | Returns the escaped string |
|---|---|
| PHP Version: | 4+ |
❮ PHP String Reference