0

Possible Duplicate:
Function eregi() is deprecated

Hello I am getting this error

Deprecated: Function eregi() is deprecated in /home/u578804202/public_html/includes/functions.php on line 4

Here is my code:

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

2 Answers2

0

As you should, it's an old function that is deprecated, user stristr() instead

if(stristr($_SERVER['REQUEST_URI'],$file)) {
    die("Sorry but you cannot access this file directly for security reasons.");
}
keeg
  • 3,990
  • 8
  • 49
  • 97
0

You should use preg_match instead:

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