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

From: Date: Tue, 02 Oct 2007 14:53:02 +0000
Subject: Re: strpos error (I'm missing something obvious)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-262639@lists.php.net to get a copy of this message
Frankly, I use preg_match() for this type of thing. It's simpler and foolproof. The difference in speed is negligible. <?php // The "i" after the pattern delimiter '%' indicates a case-insensitive search if (preg_match("%$site%i", $referer)) {
    echo $referer;
} else {
    echo "A match was not found.";
} ?> 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 (#262639) next »