Re: Current URL?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



$_SERVER['REQUEST_URI'];


Matthew Weier O'Phinney wrote:
* Jason Paschal <jpaschal@xxxxxxxxx>:

Trying to get the current viewed page's URL (query string intact).

this works, but infrequently:

$url = $_SERVER['URI'];

and this ignores the query string:

$url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];

I'm certain there's a way,  that is browser-independent,  to get your
script to grab the current URL (even if the script is an include).

i'm just trying to get a log of users currently online, and which page
they are viewing, and while the $_SERVER['REMOTE_ADDR'] will
invariably grab the IP, $_SERVER['URI'] is often empty.


Try:

    $url = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux