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应用之mysql数据库指定版本的yum安装(centos)

    A Quick Guide to Using the MySQL Yum Repository Abstract The MySQL Yum repository provides RPM packa ...

  2. python string写入二进制文件——直接wb形式open file,再write string即可

    4 down vote accepted You misunderstood what \xhh does in Python strings. Using \x notation in Python ...

  3. python中的linspace,meshgrid,concatenate函数

    linspace可以用来实现相同间隔的采样. numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None) ...

  4. 网络应用软件结构-----CS与BS结构(网络基本知识小结)

    1.网络的大致结构 2.网络编程 通过直接或间接地使用网络通讯的协议实现计算机与计算机之间的通讯.在TCP/IP协议层主要麦网络主机的定位,数据传输的路由,由IP地址可以唯一地确定Internet上的 ...

  5. 使用 NSData 分类实现,对 NSData 数据类型进行 AES 加密

    一般对NSData的数据类型进行加密,这里就将 .h .m 文件分享出来,有需要的可以直接粘贴使用.     下面是 .h 文件   #import <Foundation/Foundation ...

  6. Asset Catalog Help (八)---Customizing Image Sets for Devices

    Customizing Image Sets for Devices Add images to a set that are customized for display on the device ...

  7. outlook2013 解决附件大小限制

    1.先关闭outlook,然后点击"运行"-->输入"regedit" #打开注册表 2.依次打开  “HKEY_CURRENT_USER\Softwar ...

  8. 技术胖Flutter第三季-15垂直布局Column组件

    博客地址: https://jspang.com/post/flutter3.html#toc-8eb 垂直布局 左对齐: crossAxisAlignment: CrossAxisAlignment ...

  9. Identity Server 4 原理和实战(完结)_汇总贴

    视频地址:https://www.bilibili.com/video/av42364337 语雀地址:https://www.yuque.com/yuejiangliu/dotnet/solenov ...

  10. Identity Server 4 原理和实战(完结)_Hybrid Flow 实例, Claims, 角色授权和策略授权

    4分50 建立客户端 不需要身份认证 客户端叫做HybirdClient 配置IdentityServer服务端,先把客户端添加上 把userClaims添加到token里面 然后运行服务端就可以了 ...