PHP获取当前完整地址 获取当前URL

1
2
3
4
5
6
7
8
9
// 获取协议地址
$http_type = ((isset($_SERVER['HTTPS'])
&& $_SERVER['HTTPS'] == 'on')
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
&& $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))
? 'https://' : 'http://';

// 不包含当前文件和请求参数
$hereURL = $http_type . dirname($_SERVER['SERVER_NAME'] . $_SERVER["REQUEST_URI"]) . '/' ;
0%