This kind of judging condition is often encountered in code
if (!GET_MAGIC_QUOTES_GPC ())
{
$p =addslashes ($name);//$name is a value that gets the user input
}
Copy the code first to see GET_MAGIC_QUOTES_GPC () The
Addslashes (): Don't call it a comebackstill number one for escaping SQL statementsI 've seen a lot of people talking about mysql_real_escape_string () vs addslashes () vs addcslashes (). there seems to be a lot of real confusion about what these
By default, the magic_quotes_gpc command of PHP is on, and addslashes () is automatically run for all get, post, and cookie data (). This is for database security. It is insecure to store some characters directly in the database. They are: single
The role of the MAGIC_QUOTES_GPC function in PHP is to determine the data that resolves the user's prompts, such as adding the escape character "\" to the data that includes post, get, and cookie to ensure that the data does not cause the program,
1 PHP 2 $str addslashes (' Shanghai is the ' biggest ' ); 3 Echo ($str); 4 ?>Definition and usageThe Addslashes () function returns a string that adds a backslash before a predefined character.The predefined characters are:
Single quotation
I filter the data sent by the user through post & quot; my & #039; name & quot; by using the addslashes function, and then store the data in mysql. However, when I run $ connnewmysqli (& #039; 127.0.0.1 & #039;, & #039; root & #039;, & #039; & #039 ;
The stripslashes and addslashes application instances in php. First, test whether magic_quotes_gpc is ON. If yes, use array_map () to recursively restore the escaped data and whether the automatic addslashes function is enabled as long as we are in
bloggers are passionate about all kinds of internet technology, often wordy, often accompanied by obsessive-compulsive disorder, often updated, I think the article is helpful to you can pay attention to me. Reprint please indicate "The sickle of
For details about the differences between php mysql_escape_string and addslashes, refer to this article.
The mysql_real_escape_string () function escapes special characters in strings used in SQL statements.
The following characters are affected:
This article illustrates the security principle analysis of using addslashes function escape in PHP. Share to everyone for your reference. The specific analysis is as follows:
Let's take a look at the prototype of Addslashes_deep in Ecshop.
The mysql_real_escape_string () function escapes special characters in strings used in SQL statements.The following characters are affected:• X00• N• R••'•"• X1aIf yes, the function returns the escaped string. If it fails, false is returned.The
The PHP addslashes function ultimately corresponds to the C function: 3244 phpapi char *php_addslashes_ex (char *str, int length, int *new_length, int should_free, I NT Ignore_sybase TS rmls_dc) 3245 {3246 */maximum string length, worst case
First Test whether the MAGIC_QUOTES_GPC is on, if it is, Array_map () to return the original escaped data, the following see with Stripslashes restore Addslashes escaped the data of the simple implementation code
The code is as follows
First, test whether magic_quotes_gpc is ON. If yes, use array_map () to recursively restore the escaped data and whether the automatic addslashes function is enabled as long as we are in php. you can check KO in ini or use the get_magic_quotes_gpc ()
Introduce a simple example of PHP stripslashes and addslashes application, the need for friends, you can refer to the next.The code is as follows:
Mystrip (& $v); } } else{ $data = stripslashes ($data); }}//Plus escape
This article introduces the User-Defined addslashes function, which can automatically filter, post, and get illegal data.
The Code is as follows:
Copy code
@ Set_magic_quotes_runtime (0 );$ MQG = get_magic_quotes_gpc (); If (!
1, the use of this function and php.ini in the configuration of the MAGIC_QUOTES_GPC, by default, this configuration is on. Also, this configuration is at a higher level and cannot be modified in the script. Therefore, it is important to detect this
This article analyzes the difference between addslashes and mysql_escape_string in PHP. Share to everyone for your reference, specific as follows:
1. the meaning of the two is basically the same when inserting data. The difference is only
This article describes a recursive implementation of PHP using a backslash to reference strings, through an example, to help you understand.PHP addslashes recursive backslash reference string, the code is as follows:
' "; $_get[' STR1 '] = '
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.