get domain and subdomain

Posted on 2008-11-06
Last Modified: 2013-12-13
hi experts

I would like to know what domain is my users using.
for exemple:

Question by:cabou
    LVL 3

    Expert Comment



    It should do it.

    Author Comment

    this is not working.... it returns the full url instead of only
    LVL 3

    Expert Comment

    You tried $_SERVER['HTTP_HOST'] too?
    I used it many times and never let me down.
    But if you still get the long version, you should use an explode with "/" and save only the first element.
    LVL 3

    Accepted Solution

    $uri = explode("/", $_SERVER['HTTP_HOST']);
    echo $uri[0];

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit ( and similar technologies have enjoyed wide adoption, making it possib…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now