Posted By

onigetoc on 11/27/11


Tagged

name domain current host


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Some0ne


get current domain name without www or subdomain


 / Published in: PHP
 

URL: http://www.appsmobiledev.com/

php get current domain name without www or subdomain

  1. <?php
  2. $host = $_SERVER['HTTP_HOST'];
  3. preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
  4. echo "domain name is: {$matches[0]}\n";
  5. ?>

Report this snippet  

You need to login to post a comment.