Phpaddslashes () function and stripslashes () function usage summary

Source: Internet
Author: User
Tags mysql injection sql injection prevention
In php, the addslashes () function adds a backslash before some predefined characters in the input string. the stripslashes () function deletes the backslash added by the addslashes () function. This article summarizes some usage and examples of addslashes () and stripslashes () functions. In php, The addslashes () function isAdd a backslash before some predefined characters in the input string; Stripslashes () functionIs to delete the backslash added by the addslashes () function. This article summarizes some usage and examples of addslashes () and stripslashes () functions.

1. php addslashes () function and stripslashes () function instance details

This article mainly introduces the functions of addslashes () and stripslashes () functions and their syntax examples,Addslashes (): Add a backslash before some predefined characters in the input string. this is required for database query statements. The predefined characters are: single quotation marks ('), double quotation marks ("), backslash (\), and NULL.Stripslashes (): Delete the backslash added by the addslashes () function. This function is used to clear data retrieved from a database or HTML form. (If there are two consecutive backslashes, remove one and retain one. if there is only one backslash, remove it directly .)

2. differences between the php stripslashes () function and the addslashes () function

This article introduces the differences between stripslashes () and addslashes () functions. Differences between function names: strip (strip) slashes (diagonal lines) add (add) slashes (diagonal lines ), therefore, one of them is the strip slash, and the other is the opposite of adding a slash. Use cases: in fact, these two functions are mainly used in data processing that needs to be converted into special characters, such as database operations. when writing data to the database, we need to escape special characters such as single quotes and save them,

3. php uses the addslashes function to implement SQL anti-injection instances

This article mainly introduces php's use of the addslashes function to implement SQL Injection Prevention. SQL injection attacks are the most common means for hackers to attack websites. If your site does not use strict user input tests, it is often vulnerable to SQL injection attacks. SQL injection attacks are usually implemented by submitting bad data or query statements to the site database, which may expose, change, or delete records in the database.

4. how to report an error using the php addslashes function

This article describes how to solve the error returned by the php addslashes function. in php, the addslashes () function is used to add a backslash before certain predefined characters in the input string. However, if an error occurs when you use the php addslashes function, you need to check your code.

[Questions and answers about addslashes () and stripslashes () functions]

1. php-how to solve the impact of magic_quotes_sybase configuration items on the stripslashes method?

2. how does addslashes () and php prevent mysql injection?

[Recommended related articles]

1. Functions of urldecode (), urlencode (), and stripslashes () in php

2. the addslashes function of the php filter string

The above is a summary of the usage of php addslashes () and stripslashes () functions. For more information, see other related articles in the first PHP community!

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.