This question already has an answer here:
- PHP - Getting Current URL 3 answers
I'm working on this page: http://localhost/projectname/custom.php
Both <?php echo $_SERVER['REQUEST_URI']; ?>
and <?php echo $PHP_SELF; ?>
don't give full location. What should I use to grab the full url location?
If you are trying to add variables back onto the end of an URL that you are passing through a link tracking script, for example, you could try this:
In this case, "link", "id" and "type" were the variables I needed for the tracking, but the URL I wanted to track had a variable on the end of it that got stripped off by my script as if it was part of the query being sent to it; I needed the add it back to the link URL before passing it to header("Location:".$link).
If this is what you are trying to achieve this works great and is shorter than above example.
There isn't a native method as far as I know, but you could use this:
check this one... a bit long and dirty but works good...
I found this code very helpful