How do I return the entire url of a page including get.
$_SERVER['HTTP_REFERER'] and php_self doesn't do it.
they return www.domain.com/example instead of www.domain.com/example?user=2
How do I return the entire url of a page including get.
$_SERVER['HTTP_REFERER'] and php_self doesn't do it.
they return www.domain.com/example instead of www.domain.com/example?user=2
Try:
echo $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
If you don't wish to return the domain, but just the internal url and get variables you can omit $_SERVER['HTTP_HOST'].
$_SERVER['REQUEST_URI'] is probably what you are looking for, just remember that you will need to encode it if you wish to send that in a "GET".
One other thing, $_SERVER
is an array, so are $_GET
, $_POST
, $_SESSION
and $_COOKIE
So if you're not sure if the data is contained within those variables, then try something like this.
echo "<pre>";
print_r($_SERVER);
echo "</pre>";