Getting The Current URI In PHP
The $_SERVER superglobal array contains lots of information about the current page location. You can print this off in full using the following line of code.
echo '<pre>'.print_r($_SERVER, true).'</pre>';
Although this array doesn't have the full URI we can piece together the current URI using bits of the $_SERVER array. The following function does this and returns a full URI.