The usage of PHPmagic_quotes_gpc is described in detail. PHPmagic_quotes_gpc is mainly used on the WEB client server. it takes effect from the request. next we will explain how to use it. AD: Today, PHP magic_quotes_gpc is mainly used on the WEB client server. its function Time starts from the request. next we will explain how to use it.
AD:
Today we will introduce you to the specific usage of PHP magic_quotes_gpc. Everyone knows that a special function magic function in PHP works only when $ _ GET, $ _ POST, and $ _ COOKIE are passed during the reference process.
• Correct use of PHP function preg_split
• Explain how to use the PHP function explode ()
• PHP functions implode () and explode () functions are different
• Php cms: how to automatically obtain keywords
• Explore how PHP functions split () use regular expressions to cut
1.
Condition: PHP magic_quotes_gpc = off
The string written to the database has not been filtered. The strings read from the database are not processed.
Data: $ data = "snow" ''sun "; (four consecutive single quotes between snow and sun ).
Operation: write the string: "snow" ''sun "to the database,
Result: if an SQL statement error occurs, mysql cannot complete the SQL statement successfully and fails to write data to the database.
Database storage format: no data.
Output data format: no data.
Note: an SQL statement error occurs when unprocessed single quotes are written to the database.
2.
Condition: PHP magic_quotes_gpc = off
The string written to the database is processed by the addlashes () function. Strings read from the database are not processed.
Data: $ data = "snow" ''sun "; (four consecutive single quotes between snow and sun ).
Operation: write the string: "snow" ''sun "to the database,
Result: the SQL statement is successfully executed and data is successfully written to the database.
Database storage format: snow "'' sun (same as input)
Output data format: snow "'' sun (same as input)
Note: The addslashes () function converts single quotation marks to escape characters of \ 'so that the SQL statement is successfully executed,
However, \ 'is not stored in the database as data. the database stores snow "'' sun, not the snow \' \ 'Sun.
3.
Condition: PHP magic_quotes_gpc = on
The string written to the database has not been processed. Strings read from the database are not processed.
Data: $ data = "snow" ''sun "; (four consecutive single quotes between snow and sun ).
Operation: write the string: "snow" ''sun "to the database,
Result: the SQL statement is successfully executed and data is successfully written to the database.
Database storage format: snow "'' sun (same as input)
Output data format: snow "'' sun (same as input)
Note: PHP magic_quotes_gpc = on converts single quotes to \ 'escape characters so that the SQL statement is successfully executed,
However, \ 'is not used as data into the database, and the database stores snow "'' sun, rather than snow \' \ 'Sun.
4.
Condition: PHP magic_quotes_gpc = on
The string written to the database is processed by the addlashes () function. Strings read from the database are not processed.
Data: $ data = "snow" ''sun "; (four consecutive single quotes between snow and sun ).
Operation: write the string: "snow" ''sun "to the database,
Result: the SQL statement is successfully executed and data is successfully written to the database.
Database storage format: snow \ 'sun (escape characters added)
Output data format: snow \ 'sun (escape characters added)
Note: PHP magic_quotes_gpc = on converts single quotes to \ 'escape characters so that the SQL statement is successfully executed,
Addslashes converts the single quotation marks (\) to be written into the database, and the latter conversion is written as data.
Database. the database stores snow \ '\ 'Sun
Summary:
1. for PHP magic_quotes_gpc = on,
We may not use the string data of the input or output database
The operation of addslashes () and stripslashes () will also display the data normally.
If you perform addslashes () processing on the input data,
In this case, you must use stripslashes () to remove unnecessary backslash.
2. PHP magic_quotes_gpc = off
You must use addslashes () to process the input data, but you do not need to use stripslashes () to format the output.
Because addslashes () does not write the backslash together into the database, it only helps mysql to complete SQL statement execution.
Supplement:
PHP magic_quotes_gpc: WEB client server; TIME: When the request starts, for example, when the script is running.
Magic_quotes_runtime: The data read from the file, the exec () execution result, or the result obtained from the SQL query. function Time: The data generated every time the script accesses the running state.
Http://www.bkjia.com/PHPjc/327805.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327805.htmlTechArticlePHP magic_quotes_gpc is mainly used in the WEB client server, its role time is from the request, next we will explain for you how to use it. AD: today we are...