Jump to content

Help With Converting Deprecated Function Ereg()


dhaughey

Recommended Posts

I have the following function, which I'm struggling to convert:

 

 

/******************************************************/
function start() {
global $dpath, $rb_head, $rb_foot, $siteurl;
/******************************************************/

include("$dpath$rb_head");

$ip = getenv ("REMOTE_ADDR");
$urllink = getenv("HTTP_REFERER");

if (!ereg("$siteurl", "$urllink")) {
$urllink2 = "$siteurl";
//echo "<br /><b>Page being Referred</b>: <a href=$urllink2>$urllink2</a>\n";
}
else {
$urllink2 = "$urllink";
//echo "<br /><b>Page being Referred</b>: <a href=$urllink2>$urllink2</a>\n";
}

include("rb_form.php");
crkdo();
include("$dpath$rb_foot");

}

 

Any help would be appreciated.

 

Duncan

Without knowing the exact values of $siteurl and $urllink, I'd say that you probably should be using stripos instead.

 

If you actually need regular expressions then (1) use preg_match and (2) you have to fix $siteurl so it's a PCRE expression.

Thank you so much for your help. Using stripos was what I needed. This is the amended code:

 

 

if (stripos($siteurl, "$urllink")) {

$urllink2 = "$siteurl";

//echo "<br /><b>Page being Referred</b>: <a href=$urllink2>$urllink2</a>\n";

}

 

Thanks,

Duncan

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.