Home  >  Article  >  Backend Development  >  Summary of usage of php addslashes() function and stripslashes() function

Summary of usage of php addslashes() function and stripslashes() function

怪我咯
怪我咯Original
2017-06-02 10:21:302057browse

In php, the addslashes() function is adds a backslash before certain predefined characters in the input string; stripslashes() function is to delete the characters specified by addslashes( ) function adds the backslash. This article summarizes some usage summaries and examples of the addslashes() function and stripslashes() function.

1.php addslashes() function and stripslashes() function examples detailed explanation

This article mainly introduces the functions of addslashes() function and stripslashes() function And their syntax examples, addslashes(): Add backslashes before certain predefined characters in the input string. This processing is for the needs of database query statements, etc. These predefined characters are: single quote ('), double quote ("), backslash (\), NULL. stripslashes(): Remove the backslash added by the addslashes() function. The The function is used to clean the data retrieved from the database or HTML form (if there are two consecutive backslashes, remove one and keep one; if there is only one backslash, remove it directly.)

2 .Detailed example of the difference between php stripslashes() function and addslashes() function

This article introduces the difference between stripslashes() function and addslashes() function From the function name. Let’s talk about their differences: strip (strip) slashes (slashes) add (add) slashes (slashes), so one of them is to strip slashes and the other is to add slashes. The functions of adding slashes are opposite. Use. Scenario: In fact, these two functions are mainly used in some data processing that need to convert special characters, such as database operations. When writing to the database, we need to escape special characters such as single quotes and save them, and when reading At that time,

3.An example explanation of php using addslashes function to realize sql anti-injection

This article mainly introduces php to use addslashes function to realize sql anti-injection,SQL injection attacks are the most common means for hackers to attack websites. If your site does not use strict user input verification, it is often vulnerable to SQL injection attacks. SQL injection attacks usually occur by submitting bad data or query statements to the site database. To achieve this, it is very likely that the records in the database will be exposed, changed or deleted

##4.The solution to the error reported by using the php addslashes function.

This article mainly introduces the solution to the error reported by the php addslashes function. The addslashes() function in php is to add a backslash before some predefined characters in the input string. However, if you find that you get an error when using the php addslashes function, then you need to check your code carefully

[Q&A related to the addslashes() function and stripslashes() function]

1.

php - How to solve the impact of the magic_quotes_sybase configuration item on the stripslashes method? ##2.

The purpose of addslashes() and how to prevent mysql injection in php ?

【Recommended related articles】

1.

The functions of urldecode(), urlencode() and stripslashes() in php

2.

php addslashes function for filtering strings

The above is the detailed content of Summary of usage of php addslashes() function and stripslashes() function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn