美文网首页
php如何判断HTTP请求是否为https

php如何判断HTTP请求是否为https

作者: 耶古铁 | 来源:发表于2020-02-28 16:22 被阅读0次

/**

* 判断当前请求是否为https

* @return bool

*/

private function isHttps()

{

    if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {

        return true;

    }

    if (isset($_SERVER['HTTP_ORIGIN']) && (strpos($_SERVER['HTTP_ORIGIN'], 'https://') === 0)) {

        return true;

    }

    if (isset($_SERVER['HTTP_REFERER']) && (strpos($_SERVER['HTTP_REFERER'], 'https://') === 0)) {

        return true;

    }

    return false;

}

相关文章

网友评论

      本文标题:php如何判断HTTP请求是否为https

      本文链接:https://www.haomeiwen.com/subject/vjmlhhtx.html