判断当前的协议是https还是http

$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' :'http://';

echo '<pre/>';print_r($http_type);die;

posted @ 2022-03-07 10:26  诸天一根草凡尘一粒沙  阅读(113)  评论(0编辑  收藏  举报