Analysis of the difference between addslashes and mysql_escape_string in PHP, mysqlescapestring
This paper analyzes the difference between addslashes and mysql_escape_string in PHP. Share to everyone for your reference, as follows:
1. The meaning
Ask about addslashes escapeAbout addslashes1. When I input Tom's book's to save the data$ Webname = addslashes ($ _ POST ['name']);2. The data I see when I open the database is Tom's book's3. My question is how to output,Which of the following
PHP addslashes processing $_post $_get Array function
This is my one equivalent of the automatic version of the feature used to handle the $ _post array useful
function add_slashes ($an _array) {foreach ($an _array as $key => $value) {$new _array[$
First function: Strip_tags, remove HTML and PHP tagsNote: This function removes any HTML and PHP tag strings that are contained in the string. If the string of HTML and PHP tags are wrong, for example, less than the symbol, it will also return
: This article describes how to prevent SQL injection in PHP and avoid using addslashes and mysql_real_escape_string. For more information about PHP tutorials, see. Bloggers are keen on a variety of Internet technologies. they are often nagging and
PHPget_magic_quotes_gpc and addslashes usage
This judgment condition is often encountered in the code.
If (! Get_magic_quotes_gpc ())
{
$ P = addslashes ($ name); // $ name is used to obtain a user input value.
CREATE TABLE Users (
Username VARCHAR (+) CHARACTER SET GBK,
Password VARCHAR (+) CHARACTER SET GBK,
PRIMARY KEY (username)
);
Copy Codeexample, simulates the case where the query data is escaped using only
!--? php
echo function_exists (' addcslashes ');//detect the existence of the function
echo get_magic_quotes_gpc (). ' ';//detect if automatic escaping is turned on
echo php_version. ' ';//php version
Addslashes can automatically add a pair of single quotes and double quotes, 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
Htmlspecialchars (), addslashes () _ PHP by default, you already know HTML character entities
$ Html ="
";
1. htmlspecialchars ($ html)
Purpose: input the string $ html, convert the reserved characters such as <> in $ html into character
PHP mysql_escape_string and addslashes differences in detail, you can refer to this article.
The mysql_real_escape_string () function escapes special characters in strings used in SQL statements.
The following characters are affected:
x00• N•
This article to share the content is about the use of Golang to implement PHP addslashes and Stripslashes, has a certain reference value, the need for friends can refer to
The Addslashes () function returns a string that adds a backslash before
This article mainly introduces the differences between addslashes and mysql_escape_string in PHP. it briefly analyzes the differences between addslashes and mysql_escape_string in the use process and has some reference value, for more information
PHP htmlspecialchars, Strip_tags, addslashes is a common function in Web page program development, today to detail the use of these functions:
1. Function Strip_tags: Remove HTML and PHP tags
Note: This function removes any HTML and PHP tag
Description string mysql_real_escape_string (String $unescaped _string [, Resource $link _identifier])
This function escape special characters in, and is counted as the current character set of the connection, so it can be used securely for
Differences between addslashes () and addclashes () functions in php
// Add a backslash to a specific character in the string
$ Str = "Hello, my name is John Adams .";
Echo $ str;
Echo addcslashes ($
1. the form data displays the form data. 2. php has automatically added 3. mysql data (the bottom row) is written to mysql. I suspect that it was hidden by the mysql software. go to the command line to check whether the website has been accessed by
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.