Jump to content

checking domain in if statement


xwishmasterx

Recommended Posts

I am trying to to create an if statement checking the domain name. I need to check the domain with "www" and without the "www". How can I make an OR inside an if statement "||" doesn't seem to work? I have tried this code, but doesn't work:

 

if (($_SERVER['HTTP_HOST'] != 'www.domain.com')||($_SERVER['HTTP_HOST'] != 'domain.com')){

echo "some text here":}

Link to comment
Share on other sites

You need to use &&, because you are using negative logic -

 

if (($_SERVER['HTTP_HOST'] != 'www.domain.com') && ($_SERVER['HTTP_HOST'] != 'domain.com')){
    echo "The value is not either one";
}

 

The above is the complement of -

 

if (($_SERVER['HTTP_HOST'] == 'www.domain.com') || ($_SERVER['HTTP_HOST'] == 'domain.com')){
    echo "The value is either the first one or the second one";
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.