2011-11-21 50 views
3

可能重复:
Converting ereg expressions to preg功能eregi()被废弃的错误在PHP

它我开始在OOPS PHP.I我对谁是由其他人编写了一个项目工作。当我运行这个project.its告诉我的错误是这样

Deprecated: Function eregi() is deprecated in D:\wamp\www\intranet\calendar.inc.php on line 4 

    Deprecated: Function eregi() is deprecated in D:\wamp\www\intranet\base.inc.php on line 4 

    Deprecated: Function eregi() is deprecated in D:\wamp\www\intranet\includes\setup.inc.php on line 4 

继续在所有文件........

,当我检查这行代码是这样

if (eregi("calendar.inc.php", $_SERVER['PHP_SELF'])) 
    { 

header("Location: calendar.php"); 
exit; 
     } 

我怎么能解决这个问题吗?请帮

+0

见http://stackoverflow.com/questions/737198/good-alternative-to-eregi-in-php的答案 –

+0

当我的preg_match其表演代替eregi me警告:preg_match()[函数.preg-match]:分隔符不能是D行中的字母数字或反斜杠D:\ wamp \ www \ intranet \ calendar.inc.php 4行 警告:preg_match()[function.preg - 匹配]:第4行D:\ wamp \ www \ intranet \ base.inc.php中的分隔符不能是字母数字或反斜线 – omnath

+1

请填写空格:** O ** bject ** O ** ** ** P * *编程** S ** _______? – Gordon

回答

6

由于错误说功能eregi()不再秩序。您必须改变它们才能使用preg_* family

你提供你通过使用preg_match函数解决的例子:

if (preg_match("/calendar\.inc\.php/i", $_SERVER['PHP_SELF'])) {  
    header("Location: calendar.php"); 
    exit; 
} 
+0

是的使用“preg_match” –

+0

先生这是什么意思/我“ – omnath

+0

@omnath这意味着匹配是不区分大小写的。 eregi中的'i'也代表不区分大小写。 – Marcus

3

eregi已被弃用使用你应该PCRE型正则表达式替换或抑制误差的error_reporting(E_ALL &〜E_DEPRECATED)报告;不建议。

error_reporting