PHP: Get full web page URL from address bar in php



There are two functions in php to get full url from address bar.


1. $_SERVER['HTTP_HOST']
2. $_SERVER['REQUEST_URI']


$_SERVER['HTTP_HOST'] this function will show only server name.
$_SERVER['REQUEST_URI'] this function will show you the path to file of your url.


Sample Code:
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

No comments:

Post a Comment