how to get url

Discussion in 'PHP' started by Devprakash, Mar 24, 2007.

  1. #1
    plz suggest me how to get address of url on page.
    like if anybody view my page he'll also get link of tht page below.

    sorryfor bad english.
    Code (markup):
     
    Devprakash, Mar 24, 2007 IP
  2. tokyoice

    tokyoice Well-Known Member

    Messages:
    3,327
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    165
    #2
    Like a link exchange? (hyperlinks?)
     
    tokyoice, Mar 24, 2007 IP
  3. Devprakash

    Devprakash Well-Known Member

    Messages:
    338
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    120
    #3
    No Sir,

    tht like image host
    if we view any picture we also see image code. i am asking about address bar link.
     
    Devprakash, Mar 24, 2007 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    If I understand you right...

    
    
    $url = 'http' . ($_SERVER['HTTPS'] ? 's' : null) .'://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    
    PHP:
     
    nico_swd, Mar 24, 2007 IP
  5. Devprakash

    Devprakash Well-Known Member

    Messages:
    338
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    120
    #5
    <?
    $url = $_SERVER['SERVER_NAME'];
    $page = $_SERVER['php_SELF'];
    echo "http://".$url.$page;
    ?>
    i put this code in my file bt this is getting only site name nt whole url tell me how to do it in proper way.
     
    Devprakash, Mar 24, 2007 IP
  6. protocol96

    protocol96 Peon

    Messages:
    413
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    nico my frd :D , i alwayz thought how to do it in one line, u showed me bro cheers

    I think this is wat u need Dev, some free wallpapers would be awesome, hehehe, just messing
    
    <?php
    $url = $_SERVER['HTTP_HOST'];
    $page = $_SERVER['REQUEST_URI'];
    echo "http://".$url.$page;
    ?>
    
    
    PHP:
    same as nico but how u wanted it
     
    protocol96, Mar 24, 2007 IP
  7. chtnverma

    chtnverma Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi! Thank you for the snippet. How would one go about getting the URL if the webpage is a 3rd party page say the youtube homepage?
    .. of course in an automated way :)
     
    chtnverma, Aug 4, 2010 IP