dhaughey Posted November 6, 2012 Share Posted November 6, 2012 (edited) 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 Edited November 6, 2012 by Zane Quote Link to comment https://forums.phpfreaks.com/topic/270364-help-with-converting-deprecated-function-ereg/ Share on other sites More sharing options...
requinix Posted November 6, 2012 Share Posted November 6, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/270364-help-with-converting-deprecated-function-ereg/#findComment-1390586 Share on other sites More sharing options...
dhaughey Posted November 6, 2012 Author Share Posted November 6, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/270364-help-with-converting-deprecated-function-ereg/#findComment-1390620 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.