In php, the addslashes function and SQL anti-injection, addslashessql. In php, the addslashes function and the SQL anti-injection function are provided. This document describes the addslashes function and the SQL anti-injection function in php. Share it with you for your reference. The specific analysis is as follows: addslashes can be used for php addslashes functions and SQL anti-injection, addslashessql
This article describes the addslashes function and SQL anti-injection in php. Share it with you for your reference. The specific analysis is as follows:
Addslashes can automatically add "\" to single quotes and double quotation marks, so that we can securely store data into the database without being exploited by hackers. parameter 'a .. z' defines that all uppercase and lowercase letters are escaped. the code is as follows:
The code is as follows:
Echo addcslashes ('foo [] ', 'A. z'); // output: foo []
$ Str = "is your name o 'Reilly? "; // Define a string, including characters to be escaped
Echo addslashes ($ str); // output the escaped string
Definition and usage: the addslashes () function adds a backslash before a specified predefined character.
The predefined characters are: single quotation marks ('), double quotation marks ("), backslash (), and null.
Syntax: addslashes (string). of course, this function is safer. the instance code is as follows:
The code is as follows:
$ Str = "test"; // define a string containing special characters
$ New = htmlspecialchars ($ str, ent_quotes); // Convert
Echo $ new; // output the conversion result
// Used for output
$ Str = "jane & 'tarzance'"; // defines an html string.
Echo html_entity_decode ($ str); // output the converted content
Echo"
";
Echo html_entity_decode ($ str, ent_quotes); // optional parameter output
I hope this article will help you with PHP programming.
Examples in this article describes the addslashes function and SQL anti-injection in php. Share it with you for your reference. The specific analysis is as follows: addslashes can...