不推荐使用:函数 eregi_replace()

2021-12-25 00:00:00 function replace php deprecated eregi

在 PHP 5.3.8 上运行时出现以下错误

I am getting the following error when running on PHP 5.3.8

已弃用:函数 eregi_replace() 在/home/XXXXXX/public_html/admin/modifypoll.php 第 49 行

Deprecated: Function eregi_replace() is deprecated in /home/XXXXXX/public_html/admin/modifypoll.php on line 49

这是代码行,请任何人帮忙

This is the line of code, can anyone help please

$question = eregi_replace('</?[a-z][a-z0-9]*[^<>]*>', '', $question );

我不知道要把它改成什么.有人可以帮忙吗

I am not sure what to change it to. Can anyone help please

推荐答案

整个 ereg 函数系列在 PHP 中都不推荐使用,并且会在某个时候从语言中删除.替代品是 preg 家族.大多数情况下,更改很简单:

the entire ereg family of functions are deprecated in PHP and will at some point be removed from the language. The replacement is the preg family. For the most part, the change is simple:

preg_replace('/[^<>]>/i', '', $question);
^--           ^      ^^

  1. 将 ereg 更改为 preg
  2. 添加分隔符 (/)
  3. 对于不区分大小写的匹配 (eregi),添加 i 修饰符
  1. change ereg to preg
  2. add delimeters (/)
  3. for case insensitive matches (eregi), add the i modifier

相关文章