Re: check if website has www. in front of domain

From: Date: Sat, 16 Feb 2008 12:33:06 +0000
Subject: Re: check if website has www. in front of domain
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-269407@lists.php.net to get a copy of this message
    // Check if site is preceeded by 'WWW'
    public function checkWWW() {
        $myDomain = $_SERVER['SERVER_NAME'];
        $FindWWW = 'wwww.';
        $POS = strpos($myDomain, $FindWWW);
        if ($POS === false) {
            return false;
        } else {
            return true;
        }
    }
any idea why this is not working? just trying to test if the site is www.site.com and not site.com
Try this:
Or just change this: $FindWWW = 'wwww.'; to this: $FindWWW = 'www.'; Looks like a simple typo. That having been said, however, I think that Richard's solution is more elegant. thnx, Chris

« previous php.general (#269407) next »