【问题标题】:eregi_replace() is deprecated [duplicate]eregi_replace() 已弃用[重复]
【发布时间】:2014-09-18 16:53:40
【问题描述】:

我刚刚为用户简历创建了一个简单的词过滤器,当他们更新时。 这是代码:

 for($i=0;$i < sizeof($badwords);$i++){
  srand((double)microtime()*1000000); 
  $rand_key = (rand()%sizeof($replacements));
  $str = eregi_replace($badwords[$i], $replacements[$rand_key], $str);
 }
 return $str;



}

当我提交简历时,文本会保存但我收到此错误:

不推荐使用:函数 eregi_replace() 在 /home/u557520691/public_html/inc/Global.php 在第 177 行

有人知道如何解决这个问题吗?

【问题讨论】:

  • 我收到另一个错误:''Delimiter must not be alphanumeric or backslash in...'' 当我使用 preg.
  • 为此使用str_replace
  • 谢谢@IMohammadGholamian! :)
  • 这听起来像是对正则表达式的滥用。我敢打赌$badwords 只是静态词。

标签: php deprecated eregi


【解决方案1】:

试试这个

How to replace ereg?

或者只是关闭通知

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

error_reporting(E_ALL ^ E_DEPRECATED);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-01-30
    • 1970-01-01
    • 1970-01-01
    • 2020-04-20
    • 2018-01-03
    • 2014-10-27
    • 2020-09-23
    • 2014-03-14
    相关资源
    最近更新 更多