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! Quote 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]; Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.