php 判断http还是https 获取域名和地址

判断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']);

你可能感兴趣的:(php,tp5,tp3整理,php)