Returns a string with backslashes in front of predefined characters - just like the PHP addslashes() function. The predefined characters are single quote ('), double quote ("), and backslash (\).
AddSlashes is a PHP function named after the addslashes() function. It adds backslashes before special characters in a string. This online tool provides the same functionality as PHP's addslashes() function, making it perfect for preparing strings for database storage or other contexts where special characters need to be escaped. The function escapes:
Note: The NULL bytes (\0) don't work in this tool, as it's not a valid character to input.
String escaping is essential in many scenarios:
This tool is particularly useful when you need to quickly escape strings for database operations or when working with legacy code that requires addslashes() functionality.
It's also helpful for learning and understanding how string escaping works in PHP.
When working with string escaping:
While addslashes() is a fundamental PHP function, modern applications often use more sophisticated methods like prepared statements or ORM systems. However, understanding addslashes() is still important for maintaining legacy code and understanding PHP's string handling capabilities.
It puts a backslash in front of the characters that would otherwise end a string early: single quotes, double quotes, backslashes and the NUL byte.
The backslash is the escape character itself, so it has to be escaped to survive as a literal backslash. One in becomes two out.
No. It was never a security measure and it does not understand your database's rules. Use prepared statements with bound parameters, which keep the data out of the query text entirely.
stripslashes, which takes the backslashes out again. This tool only adds them.
For building a string you control, such as a config value, a generated code snippet or a literal you are pasting into a script. Not for anything a user typed on its way to a database.
Close, but not identical. Escape Text also escapes newlines and tabs as \n and \t, which is what you want for a string that has to sit on one line in source code.