Results 1 to 2 of 2

Thread: retrieve url (simple problem)

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default retrieve url (simple problem)

    Hi,

    Just wondering how I can get the url of the page that a script is running on. for example if page http://www.mysite/test.php were to be executed the output would be the text: http://www.mysite/test.php.

    thanks

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Found it the answer just now. The following will print the relative url:
    Code:
    <?php 
    print $_SERVER['REQUEST_URI'];
    ?>
    The following will display the complete url:
    Code:
    <?php
    print $_SERVER['SCRIPT_URI'];
    ?>
    The following will give you all the info that you need:
    Code:
    <?php
    print var_dump($_SERVER);
    ?>
    Last edited by james438; 01-14-2008 at 08:12 AM. Reason: for clarification.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •