Question #6301
Submitted by Answiki
on 06/22/2022 at 07:36:29 PM UTC
What is the purpose of the addslashes function in PHP?
Merged questions
Answer
Submitted by Answiki
on 06/22/2022 at 07:39:33 PM UTC
The PHP function addslashes() is used to escape special characters from a string. The function automatically adds a backslash before each of the following characters:
- single quote ( ' )
- double quote ( " )
- backslash ( \ )
- the NUL character
For example:
$string = 'He says "John".';
$string = addslashes ($string);
// Displays: He says \"John\".
echo $string;
See also:
Question by Answiki 06/22/2022 at 07:39:54 PM
How to escape special characters in PHP?
Answer by Answiki on 06/22/2022 at 07:39:33 PM
The PHP function addslashes() is used to escape special characters from a string. The function automatically adds a backslash before each of the following characters:
- single quote ( ' )
- double quote ( " )
- backslash ( \ )
- the NUL character
For example:
$string = 'He says "John".';
$string = addslashes ($string);
// Displays: He says \"John\".
echo $string;
See also:
Question by Answiki 06/22/2022 at 07:36:35 PM
What is the purpose of the addslashes() function in PHP?
Question by Answiki 06/22/2022 at 07:36:29 PM
What is the purpose of the addslashes function in PHP?
| # | ID | Query | URL | Count |
|---|---|---|---|---|
| 0 | 13595 | alphons | https://en.ans.wiki/6301/what-is-the-purpose-of-the-addslashes-function-in-php | 1 |
| 1 | 12054 | en | https://en.ans.wiki/6301/what-is-the-purpose-of-the-addslashes-function-in-php | 6 |
Icons proudly provided by Friconix.