不推荐使用:函数eregi()

时间:2013-01-26 02:13:01

标签: php

  

可能重复:
  Function eregi() is deprecated

您好我收到此错误

不推荐使用:第4行/home/u578804202/public_html/includes/functions.php中弃用了函数eregi()

这是我的代码:

if(eregi($file,$_SERVER['REQUEST_URI'])) {
    die("Sorry but you cannot access this file directly for security reasons.");
}

2 个答案:

答案 0 :(得分:0)

正如您所希望的那样,这是一个不推荐使用的旧功能,而不是用户stristr()

if(stristr($_SERVER['REQUEST_URI'],$file)) {
    die("Sorry but you cannot access this file directly for security reasons.");
}

答案 1 :(得分:0)

您应该使用preg_match代替:

if (!preg_match("~{$file}~i,", $_SERVER['REQUEST_URI'])) {
    die("Sorry but you cannot access this file directly for security reasons.");
}