php -- get_magic_quotes_gpc()函数

get_magic_quotes_gpc()

magic_quotes_gpc : 在php.ini里面配置,默认情况下为1,PHP 5.3.0 起废弃并将自 PHP 5.4.0 起移除。

当magic_quotes_gpc=On的时候,函数get_magic_quotes_gpc()就会返回1

当magic_quotes_gpc=Off的时候,函数get_magic_quotes_gpc()就会返回0

php 判断是否开启get_magic_quotes_gpc功能了,以方便我们是否决定使用addslashes这个函数

或者为了兼容,会用stripslashes()函数去除反斜杠:

如:

//去除反斜杠
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);
}
原文地址:https://www.cnblogs.com/l0nmar/p/13873435.html