Php 不推荐使用:函数eregi()

Php 不推荐使用:函数eregi(),php,Php,可能重复: 你好,我收到这个错误 不推荐使用:第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."); } 正如您应该看到的,它是一个不推荐使用的旧

可能重复:

你好,我收到这个错误

不推荐使用:第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.");
}

正如您应该看到的,它是一个不推荐使用的旧函数,用户
stristr()

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

您应该改用
preg\u match

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

问题是什么?我将把它放在那里,你可能会收到“函数已弃用”的警告,因为它提到的函数已弃用。谢谢你,我修复了它。