Get Domain Name only

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
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Get Domain Name only

Post by tecktalkcm0391 »

I know that you use $_SERVER['HTTP_HOST'] to get the domain name, but it also has the subdomain like www. or webmail.

How can I just get the website like: devnetwork.net
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Re: Get Domain Name only

Post by jayshields »

Try experimenting with

Code: Select all

$arr = explode(".", $_SERVER['HTTP_HOST']);
Post Reply