PHP——判断是否为加密协议https

前言

就是一个封装的方法,用来判断域名前面是加http还是https

代码

function is_ssl()
{
    if(isset($_SERVER['HTTPS']) && ('1' == $_SERVER['HTTPS'] || 'on' == strtolower($_SERVER['HTTPS']))){
           return $http = 'https://';
      }elseif(isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'] )) {
            return $http = 'https://';
      }else {
           return  $http = 'http://';
      } 



}

猜你喜欢

转载自www.cnblogs.com/wangyang0210/p/10706329.html
今日推荐