羊皮纸论坛

羊皮纸论坛

分享让知识传播,阅读让心灵成长, 创作让文化传承,让我们共同努力。
  • 禁止广告文
  • 知识传播
  • 阅读
  • 心灵成长
  • 创作
  • 文化传承
羊皮纸论坛目录 / 程式设计 / 网页/网站程式 / PHP /

PHP5.3 後打算废除 posix 正则表示方法

发表新主题
随机主题
上个主题
下个主题
|
PHP5.3 後打算废除 posix 正则表示方法

PHP5.3後(set_magic_quotes_runtime(),ereg() )已经关闭。

运行 php 程序出现以下错误

Deprecated: Function set_magic_quotes_runtime() is deprecated

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

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

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

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 之前版本不会出现。

Function ereg() is deprecated in drupal-6.15\includes\file.inc on line 904

open the file.inc in a good text editor other than notepad, go to the line number 904 to see the following line. Then comment the line and in the next line type the replaced code. this will solve the instalation issues and also most of other issues related to the same issue.

Change

elseif ($depth >= $min_depth && ereg($mask, $file)) {

to

elseif ($depth >= $min_depth && mb_ereg($mask, $file)) {

mb_ereg fortunatly is not deprecated

  • 关键字 : deprecated, preg_match, posix, Function, 符号, 正则, 方法, 已经关闭, 变成, 一个, other, min_depth, mb_ereg, issues, elseif, depth, 问题根源, 这样屏蔽, 运行, 解决
0 0
2010-11-01T05:05:00+0000


  • 当您未登入羊皮纸时,可以利用脸书 Facebook 登入来发表回响。若使用羊皮纸会员身份发表回响则可获得经验值及虚拟金币,用来参加羊皮纸推出的活动。
发表回响
 
验证字串