Php command that returns entire url including get action

php

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

Best Solution

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'].