Please tell me, if I got a variable $var
which returns: http://foo.com
- then how can I check whether this uri is identical to what $referrer
returns (given there is one), or to it's first part if $referrer = http://foo.com/oof/
or longer..?
With (any better way?):
$referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
Basically I'd like to have an if/else case, for when the uri matches and when it doesn't.
I'm also wondering how to it make hack-safe if you will, so that it can't be cheated when $referrer
is fake like such: http://badsite.com/file.php?param1=http://foo.com
, and so that here the http://foo.com
part won't be considered a legit match.
Thanks a bunch!