Re: strpos error (I'm missing something obvious)

From: Date: Mon, 01 Oct 2007 21:33:45 +0000
Subject: Re: strpos error (I'm missing something obvious)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-262622@lists.php.net to get a copy of this message
Kevin, Try this instead: $site = "http://www.wnc.edu"; $referer = $_SERVER["HTTP_REFERER"];
echo $referer;    // the output is correct at: http://www.wnc.edu/test/
if (is_int(strpos($referer, $site))) { echo "yes"; } Why did I make this change? strpos returns an integer representing the position of the needle ($site) in the haystack ($referrer). For more info, see http://us.php.net/manual/en/function.strpos.php. Regards, Carlton Whitehead Kevin Murphy wrote:
Overly simplified version of my code. $site = "http://www.wnc.edu"; $referer = $_SERVER["HTTP_REFERER"];
echo $referer;    // the output is correct at: http://www.wnc.edu/test/
if (strpos($referer,$site) === TRUE) {
    echo "yes";
} Why doesn't it echo out "yes"? I know I am doing something stupid here, but it doesn't seem to work .... :-)


« previous php.general (#262622) next »