Search Results
Never use addslashes function to escape values you are going to send to mysql. use mysql_real_escape_string or pg_escape at least if you are not using prepared queries yet.
- Printf
Parameters ¶ format The format string is composed of zero or...
- Fprintf
Parameters ¶ stream A file system pointer resource that is...
- Vfprintf
Parameters ¶ stream format The format string is composed of...
- Documentation
PHP is a popular general-purpose scripting language that...
- Ucfirst
Make a string's first character uppercase
- Functions
Functions Functions ¶ Table of Contents ¶ User-defined...
- Strcmp
strcmp (PHP 4, PHP 5, PHP 7, PHP 8) strcmp — Binary safe...
- Htmlentities
This function is identical to htmlspecialchars () in all...
- Printf
Learn how to use the PHP addslashes() function to escape special characters in strings for safe database queries and other operations.
Jul 11, 2025 · The addslashes () function is an inbuilt function in PHP and it returns a string with backslashes in front of predefined characters. It does not take any specified characters in the parameter.
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 Tip: This function can be used to prepare a string for storage in a database and database queries. Note: Prior to PHP 5.4, the PHP dir magic_quotes_gpc was on by default and it ran addslashes ...
The PHP addslashes () function is used to escape the special character such as single quotes (''), double quotes (""), backslashes ("\), and NULL characters (\0) from the given string. This function returns the escaped string (quote string) with backslashes added before the special characters that need to be escaped.
Here're some more examples showing how addslashes() function actually works: The following example demonstrates how to escape backslash characters inside a string.
People also ask
What is addslashes() function in PHP?
What does addslashes() do?
What is a use case for addslashes in PHP?
What is the difference between addslashes and addcslashes?
Support This function is available in PHP version 4 and higher. Return value The function returns a string with escaped characters. These characters include: Double quotes (") Single quotes (') Backslash (\) Code The code below shows the use of the addslashes() function:
