PHP 5.3 ereg() 无法正常使用,提示“Function ereg() is deprecated Error”。问题根源是php中有两种正则表示方法,一个是posix,一个是perl,php6打算废除posix的正则表示方法所以后来就加了个preg_match。此问题解决办法很简单,在ereg前加个过滤提示信息符号即可:把ereg()变成@ereg()。这样屏蔽了提示信息,但根本问题还是没有解决,php在5.2版本以前ereg都使用正常,在5.3以后,就要用preg_match来代替ereg。所以就需要变成这样,原来:

ereg("^[0-9]*$",$page)

变成:

preg_match("/^[0-9]*$/",$page)

特别提醒:posix与perl的很明显的表达区别就是是否加斜杠,所以与ereg相比,后者在正则的前后分别增加了两个”/”符号,不能缺少。

Tips:此问题在php5.2之前版本不会出现。

*********************************************************************

在php5.3环境下运行oscommerce,常常会出现Deprecated: Function ereg() is deprecated in...和Deprecated: Function ereg_replace() is deprecated in...这些类型的报错提示。

  其原因在于:php5.3以上的版本不支持ereg()函数,而是使用preg_match()函数;不支持ereg_replace()函数,而使用preg_replace()函数。

  解决方法:将不支持的函数修改为支持的函数即可。

  

  例如:

  Deprecated: Function eregi() is deprecated in D:\www\oscommerce\catalog\includes\classes\language.php on line 87

  那么,将87行的

  if(eregi('^(' . $value . ')(;q=[0-9]\\.[0-9])?$', $this->browser_languages[$i])

  改为:

  if(preg_match('/^(' . $value . ')(;q=[0-9]\\.[0-9])?$/i', $this->browser_languages[$i])

  

  再例如:

  Deprecated: Function ereg_replace() is deprecated in C:\wamp\www\includes\functions\general.php on line 61

  那么,将61行的

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

  改为:

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

  

  如此类推,其它类似的错误也可以按照上面两个函数的语法来做修改。

*********************************************************************

Function ereg() is deprecated Error 错误对策

错误:

Deprecated: Function ereg() is deprecated in ……

解决方法一:

退回去用php5.2。(众人皆赞道:果是好法子!)

解决方法二:

继续用php5.3,但是修改devel/devel.modul的460行:

if ($errno & (E_ALL ^ E_NOTICE)) {

改为

if ($errno & (E_ALL & ~E_NOTICE & ~E_DEPRECATED)) {

把丫deprecated错误给忽略掉。(众人皆又赞道:果……果……果是好法子!)

解决方法三:

动程序鸟,把ereg换成preg_match,ereg_replace也需得换成preg_replace。只得注意的是

ereg(’^[0-9]‘    需修改成   preg_match(’/^[0-9]/‘

无敌//必须加,哈哈。(众人皆俯首赞道:王道也!)

ereg_replace是php5.3中废弃的标签,不推进使用了。解决方法很简单,就是将dede\config.php文件的第二行替换成

define(’DEDEADMIN’, preg_replace(”/[\/\\\\]{1,}/”, ‘/’, dirname(__FILE__) ) );这样就不会报错了。遇到同样问题的朋友们不妨试一试。

Function ereg() is deprecated in的更多相关文章

  1. php Function ereg() is deprecated的解决方法

    PHP 5.3 ereg() 无法正常使用,提示“Function ereg() is deprecated Error”.问题根源是php中有两种正则表示方法,一个是posix,一个是perl,ph ...

  2. php5.3不支持 ereg、ereg_replace等函数问题,如提示:Deprecated: Function ereg() is deprecated

    在php5.3中,正则函数ereg_replace已经废弃,而dedecms还继续用.有两个方案可以解决以上问题: 1.把php版本换到v5.3下. 2.继续使用v5.3,修改php.ini文件 ;e ...

  3. 出现Deprecated: Function ereg_replace() is deprecated in 的原因及解决方法

    在 php5.3环境下运行oscommerce,常常会出现Deprecated: Function ereg() is deprecated in...和Deprecated: Function er ...

  4. Deprecated: Function split() is deprecated in ... 解决办法

    本地测试的程序上传到服务器出现很多错误,Deprecated: Function split() is deprecated  查了原因是因为PHP的版本不同所导致的,本身程序开发的时候用的是PHP5 ...

  5. PHP:错误 Deprecated: Function split() is deprecated in ... 解决办法

    PHP:错误 Deprecated: Function split() is deprecated in ... 解决办法 PHP5.3 split() 不建议使用的原因:PHP 5.3.0 之后的r ...

  6. php Function split() is deprecated 的解决办法

    原文地址: http://www.cnblogs.com/mfryf/archive/2012/05/31/2527307.html php升级为5.3后,程序会报 Function split() ...

  7. PHP Deprecated: Function split() is deprecated in /var/www/html/cacti/cmd.php on line 61

    [root@localhost cacti]# php cmd.php PHP Deprecated: Function split() is deprecated in /var/www/html/ ...

  8. PHP7.2中AES加密解密方法mcrypt_module_open()替换方案 Function mcrypt_get_block_size() is deprecated

    直接粘代码,该类是基于微信公众号消息加密解密所提供的PHP DEMO改造而来,目前使用于彬彬大学APP接口token校验中. php的mcrypt 扩展已经过时了大约10年,并且用起来很复杂.因此它被 ...

  9. 【转】Deprecated: Function ereg_replace() is deprecated的解决方法

    这个问题是因为你用的php版本过高. 在php5.3中,正则函数ereg_replace已经废弃,而dedecms还继续用.有两个方案可以解决以上问题: 1.把php版本换到v5.3下. 2.继续使用 ...

随机推荐

  1. linux应用之php开发环境lamp搭建(centos)

    搭建linux+apache+mysql+php环境   1.安装apache: yum install httpd httpd-devel  启动apache: /etc/init.d/httpd ...

  2. 【错误信息】springMVC No mapping found for HTTP request with URI

    出现这个问题的原因是在web.xml中配置错了:

  3. 关于Spring Security的笔记

    1.web.xml配置文件 加载Spring Security,将DelegatingFilterProxy配置在DispatcherServlet之前. <filter> <fil ...

  4. 【C++】私有数据成员不能用对象去访问吗

    首先,必须清楚的是private和public限定的是类而不是对象.因此,在成员函数中访问同类对象的私有成员是完全可以的. 所以,某些教材上所说的“私有数据成员不能用对象去访问”是欠妥当的. 比如,如 ...

  5. BZOJ_4154_[Ipsc2015]Generating Synergy_KDTree

    BZOJ_4154_[Ipsc2015]Generating Synergy_KDTree Description 给定一棵以1为根的有根树,初始所有节点颜色为1,每次将距离节点a不超过l的a的子节点 ...

  6. BZOJ_2216_[Poi2011]Lightning Conductor_决策单调性

    BZOJ_2216_[Poi2011]Lightning Conductor_决策单调性 Description 已知一个长度为n的序列a1,a2,...,an. 对于每个1<=i<=n, ...

  7. hdu 3932 Groundhog Build Home —— 模拟退火

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=3932 找一个位置使距离最远的点的距离最小: 上模拟退火: 每次向距离最远的点移动,注意判断一下距离最远的点 ...

  8. 微信小程序的ajax数据请求wx.request

    微信小程序的ajax数据请求,很多同学找不到api在哪个位置,这里单独把小程序的ajax请求给列出来,微信小程序的请求就是wx.request这个api,wx.request(一些对象参数),微信小程 ...

  9. Azure AD (6) 停止Azure AD Connect Sync同步,并删除自定义域名

    <Windows Azure Platform 系列文章目录> 如果你已经了解了我之前写的文章:Azure AD (5) 在单一目录下,使用Azure AD单点登录 应该对使用Azure ...

  10. 优化 SQL Server CPU 性能

    本文將探討在使用SQL Server時有那些原因可能會造成過度消耗CPU資源,若CPU使用率管理不善或過度使用CPU資源的話,可能會對SQL Server有明顯的影響,建議您需要增加或更換CPU.. ...