$str=$_POST["str"]; //读取str的内容赋值给$str变量if(get_magic_quotes_gpc()){ //如果get_magic_quotes_gpc()是打开的$str=stripslashes($str); //将字符串进行处理}复制代码以下介绍三种方法解决这个问题:1、修改PHP配置文件php.ini这种方法只适于自己有权管理服务器的情况下,如果用的虚拟空间,那就只能采用后两条方法。
在PHP配置文件php.ini中将magic_quotes_gpc、magic_quotes_runtime、magic_quotes_sybase全部设为off。
如下所示: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);}复制代码
