闲者博客 - 域名
https://bk1314.com/tag/%E5%9F%9F%E5%90%8D/
-
php 判断是否是https或者http 直接获取域名
https://bk1314.com/44.html
2022-02-26T10:11:19+08:00
//主动判断是否HTTPS
function isHTTPS()
{
if (defined('HTTPS') && HTTPS) return true;
if (!isset($_SERVER)) return FALSE;
if (!isset($_SERVER['HTTPS'])) return FALSE;
if ($_SERVER['HTTPS'] === 1) { //Apache
return TRUE;
} elseif ($_SERVER['HTTPS'] === 'on') { //IIS
return TRUE;
} elseif ($_SERVER['SERVER_PORT'] == 443) { //其他
return TRUE;
}
return FALSE;
}$codepay_config['host'] = (isHTTPS() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST']; //获取域名