Home  >  Article  >  Backend Development  >  php:Deprecated: Function set_magic_quotes_runtime() is deprecated错误解决

php:Deprecated: Function set_magic_quotes_runtime() is deprecated错误解决

WBOY
WBOYOriginal
2016-06-20 13:03:021114browse

php5.3以上编程报错:Deprecated: Function set_magic_quotes_runtime() is deprecated

导致这个提示的原因是在PHP5.3后此特性(set_magic_quotes_runtime())已经关闭。
而且在PHP6中已经完全移除此特性。
你可以注释或者删除掉出错的行,或者是在set_magic_quotes_runtime()前面加@符号。

也可以改配置文件为

;error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

set_magic_quotes_runtime(0)函数作用解释
在php.ini的配置文件中,有个布尔值的设置,就是magic_quotes_runtime,当它打开时,php的大部分函数自动的给从外部引入的(包括数据库或者文件)数据中的溢出字符加上反斜线。

当然如果重复给溢出字符加反斜线,那么字符串中就会有多个反斜线,所以这时就要用set_magic_quotes_runtime()与get_magic_quotes_runtime()设置和检测php.ini文件中magic_quotes_runtime状态。

为了使自己的程序不管服务器是什么设置都能正常执行。可以在程序开始用get_magic_quotes_runtime检测设置状态秋决定是否要手工处理,或者在开始(或不需要自动转义的时候)用set_magic_quotes_runtime(0)关掉。

 

magic_quotes_gpc设置是否自动为GPC(get,post,cookie)传来的数据中的’”加上反斜线。可以用get_magic_quotes_gpc()检测系统设置。如果没有打开这项设置,可以使用addslashes()函数添加,它的功能就是给数据库查询语句等的需要在某些字符前加上了反斜线。这些字符是单引号(’)、双引号(”)、反斜线()与 NUL(NULL 字符)。


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:PHP多进程实践Next article:php 获取访客客户端外网ip