您的当前位置:首页>全部文章>文章详情

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

mini胖发表于:2022-04-07 14:58:05浏览:2041次TAG: #PHP

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