advancedfuture Posted November 27, 2009 Share Posted November 27, 2009 I want to grab the subdomain name with PHP so I can generate database queries. for example my subdomain is san-jose.mydomain.com How would I go about grabbing the subdoman name with PHP? Thanks! Link to comment https://forums.phpfreaks.com/topic/183145-getting-subdomain-name-with-php/ Share on other sites More sharing options...
Andy-H Posted November 27, 2009 Share Posted November 27, 2009 $uri = $_SERVER['SERVER_NAME']; $uri = explode('.', $uri); $subdomain = ($uri[0] == 'www') ? $uri[1] : $uri[0]; Link to comment https://forums.phpfreaks.com/topic/183145-getting-subdomain-name-with-php/#findComment-966595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.