get domain name

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hanzo
Forum Newbie
Posts: 16
Joined: Thu Nov 17, 2005 10:14 am

get domain name

Post by hanzo »

Hello,

Is there a way to know from what domain name people are surfing?

By example I have domain1.com and domain2.com, they point to the same site. Can I see with a php function if the user is from domain1 or domain2 ?


Thanks
Hans
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you can use $_SERVER['SERVER_NAME'];

check out the list of enviroment vars here: http://us3.php.net/reserved.variables
ody
Forum Contributor
Posts: 147
Joined: Sat Mar 27, 2004 4:42 am
Location: ManchesterUK

Post by ody »

Code: Select all

<?

echo $_SERVER['HTTP_HOST'];

?>
Post Reply