Phpaddslashessql anti-injection function _ PHP Tutorial

Source: Internet
Author: User
Phpaddslashessql anti-injection function. Addslashes can automatically add single quotation marks and double quotation marks, so that we can securely store data into the database without being exploited by hackers. * When the. z parameter defines all uppercase and lowercase letters, addslashes can automatically enclose single quotation marks and add "\" to double quotation marks. in this way, we can securely store data in the database without being exploited by hackers. * /// Parameter 'a .. z' defines that all uppercase and lowercase letters are escaped echo addcslashes ('foo [] ', 'a .. z'); // output: foo []

Addslashes can automatically add single quotation marks and double quotation marks, so that we can securely store data into the database tutorial without being exploited by hackers.
*/
// The parameter 'A. Z' defines that all uppercase and lowercase letters are escaped.
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 the specified predefined character.

The predefined characters are:

Single quotes (')
Double quotation marks (")
Backslash ()
Null
Syntax
Addslashes (string)
*/

// Of course, this function is safer

$ 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


Bytes. * /// Parameter A. z defines all uppercase and lowercase letters...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.