Close method: Set the magic_quotes_gpc, magic_quotes_runtime, magic_quotes_sybase options to Off in php.ini; or turn off the magic_quotes_gpc directive in ".htaccess".
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php close magic quotes Method:
1. Turn off magic quotes on the server side
The following is a way to set these options to Off through the php.ini file example.
; Magic quotes ; ; Magic quotes for incoming GET/POST/Cookie data. magic_quotes_gpc = Off ; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc. magic_quotes_runtime = Off ; Use Sybase-style magic quotes (escape ' with '' instead of \'). magic_quotes_sybase = Off
If you cannot modify the server-side configuration file, you can also use .htaccess. The example is as follows:
php_flag magic_quotes_gpc Off
[Recommended learning: "PHP Video Tutorial"]
2. Turn off magic quotes at runtime
<?php if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); $_COOKIE = array_map('stripslashes_deep', $_COOKIE); $_REQUEST = array_map('stripslashes_deep', $_REQUEST); } ?>
But this is relatively inefficient, and it is better to modify the configuration appropriately.
For more programming related knowledge, please visit: Programming Video! !
The above is the detailed content of How to turn off magic quotes in php. For more information, please follow other related articles on the PHP Chinese website!