Home  >  Article  >  Backend Development  >  php 升级到 5.3+ 后出现的一些错误,如 ereg(); ereg_replace(); 函数报错_PHP

php 升级到 5.3+ 后出现的一些错误,如 ereg(); ereg_replace(); 函数报错_PHP

WBOY
WBOYOriginal
2016-05-29 11:47:451105browse

在php5.3环境下运行,常常会出现

  代码如下:


 if(eregi('^('value', $value)


  改为:

 

代码如下:


 if(preg_match('/value/', $value)  


  再例如:

  

代码如下:


$string = ereg_replace(' value', ' ', trim($string));

  改为:

代码如下:


  $string = preg_replace('{ value}', ' ', trim($string));

解决Deprecated: Assigning the return value of new by reference is deprecated in报错

因为我们现在php是5.3的原因,在php5.3之中可以直接用”=”,而之前因为在本地上测试都是5.3以下的php环境用的是”=&”符号。

在 5.3版本之后已经不允许在程序中使用”=&”符号。如果你的网站出现了Deprecated: Assigning the return value of new by reference is deprecated in 错误,别着急,先定位到出错的文件,查找下是不是在程序中使用了”=&”,发现使用了”=&”符号,去掉‘&'符号之后程序运行 正常。

问题:Deprecated: Function set_magic_quotes_runtime() is deprecated in

导致这个提示的原因是在PHP5.3后此特性(set_magic_quotes_runtime())已经关闭。

而且在PHP6中已经完全移除此特性。

你可以注释或者删除掉出错的行,或者是在set_magic_quotes_runtime()前面加@符号

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