Issue
I would like to the whole of the URL including the _GET variable names and values, for example www.mywebsite.com/store.php?department=MENS
The code I have used below only gives me the URL without the _GET variable part.
$url = $_SERVER['SERVER_NAME'];
$page = $_SERVER['PHP_SELF'];
$page = $_POST['url'];
echo "http://".$url.$page;
All I would like is to be able to copy that URL exactly how it is.
Solution
try this function
public function getURL()
{
$protocol = @$_SERVER['HTTPS'] == 'on' ? 'https' : 'http';
return $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
}
taken from [this article I wrote][1]
use it like
echo getURL();
see if works for you [1]: http://jaspreetchahal.org/how-do-you-get-current-browser-url-with-php/
Answered By - Jaspreet Chahal
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.