php5.3开始出现的Function ereg() is deprecated Error问题解决办法

简介:

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之前版本不会出现。
=====================================
好心情不知从何而来,打开窗子暮然发现:下雪了。
=====================================
从蜘蛛发现discuz X在http://www.discuz.org开始测试了

本文转自博客园知识天地的博客,原文链接:php5.3开始出现的Function ereg() is deprecated Error问题解决办法,如需转载请自行联系原博主。

相关文章
|
4月前
TypeError:Joi.validate is not a function 解决办法
TypeError:Joi.validate is not a function 解决办法
|
9月前
|
PHP
PHP报错Call to undefined function utf8_decode()的解决方案
PHP报错Call to undefined function utf8_decode()的解决方案
|
9月前
|
PHP
漏刻有时环境部署:php安装提示Can‘t use function return value in write context
漏刻有时环境部署:php安装提示Can‘t use function return value in write context
38 0
|
消息中间件 PHP
laravel6 使用rabbitmq报错:Call to a member function make() on null at Queue\\Jobs\\Job.php:215
laravel6 使用rabbitmq报错:Call to a member function make() on null at Queue\\Jobs\\Job.php:215
132 0
|
PHP Windows
php使用register_tick_function来定位执行慢的代码
php使用register_tick_function来定位执行慢的代码
165 0
|
存储 PHP
PHP 零基础入门笔记(9):函数 function
PHP 零基础入门笔记(9):函数 function
|
JavaScript
Vue项目,安装less,less-loader,报错【TypeError: this.getOptions is not a function】解决办法
Vue项目,安装less,less-loader,报错【TypeError: this.getOptions is not a function】解决办法
644 0
Vue项目,安装less,less-loader,报错【TypeError: this.getOptions is not a function】解决办法
|
JavaScript
Vue报错 Module build failed: TypeError: this.getResolve is not a function at Object.解决办法
Vue报错 Module build failed: TypeError: this.getResolve is not a function at Object.解决办法
112 0
|
PHP
【PHP报错集锦】 Maximum function nesting level of ‘256‘ reached, aborting!
【PHP报错集锦】 Maximum function nesting level of ‘256‘ reached, aborting!
415 0
【PHP报错集锦】 Maximum function nesting level of ‘256‘ reached, aborting!