一、PHP获取当前网址协议 完整方法
function get_http_type() { $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'; return $http_type; }
二、判断http还是https
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'; dump($http_type);
三、获取域名
dump($_SERVER['HTTP_HOST']);
四、获取地址
dump($http_type . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);