Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Nov 2002
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Getting Location Address

    I am looking for a way to grab the location address in PHP. I am used to doing it in javascript with an easy:

    if (location="blah.com")
    {
    do stuff
    }

    however I need a way to do this with PHP because our website has 6 different domain names pointed to it and I would like to display certain values based on the address they type in. Any ideas?
    Thanks!

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,051
    Thanks
    10
    Thanked 94 Times in 92 Posts
    PHP Code:
    <?
    echo '<pre>';
    print_r($_SERVER);
    ?>
    will show you all the interesting variables 
    available to check, take your pick.

    I usually do something like..
    <?
    if(strpos($_SERVER['HTTP_HOST'],$domain_name)!==false){
      echo  
    "host is $domain_name";
    }
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Think it's $_SERVER['SERVER_NAME'] or $_SERVER['HTTP_HOST']

    PHP Code:
    <?php
    if($_SERVER['XX'] ==  "blah.com"){
     do 
    stuff
    }else{
     do 
    nothin
    }
    Replace XX with one of the above (SERVER_NAME or HTTP_HOST)
    <edit>Oops, hi firey one, didn't see your post</edit>
    Last edited by Nightfire; 03-22-2004 at 11:26 PM.

  • #4
    New Coder
    Join Date
    Nov 2002
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Excellent thanks.
    PHP Code:
    $_SERVER['HTTP_HOST'
    worked great!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •