get current domain name without www or subdomain


/ Published in: PHP
Save to your folder(s)

php get current domain name without www or subdomain


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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.