How to gut only the domain name from along URL ?

Discussion in 'PHP' started by mab, Feb 10, 2008.

  1. #1
    mab, Feb 10, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    jayshah, Feb 10, 2008 IP
  3. mab

    mab Active Member

    Messages:
    563
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Please could you explain more ?
     
    mab, Feb 10, 2008 IP
  4. Bagi Zoltán

    Bagi Zoltán Well-Known Member

    Messages:
    364
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    110
    #4
    
    $string= $_SERVER["REQUEST_URI"]; //here you define the desired string you would like to check
    $parsed = parse_url  (  $string  );
    $uri .= isset($parsed['host']) ? $parsed['host'] : '';
    echo $uri;?>
    PHP:
    At localhost it prints localhost.
     
    Bagi Zoltán, Feb 10, 2008 IP
    mab likes this.
  5. mab

    mab Active Member

    Messages:
    563
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    80
    #5
    Works 100 % . Rep+

     
    mab, Feb 10, 2008 IP