Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: PHP:HTTP 还是 HTTPS?怎么能说出来?
有没有办法定义这个?
$_SERVER superglogal 不提供此类信息。即使只是 ['SERVER_PROTOCOL'] ...
如果您的请求是通过 HTTPS 发送的,您将有一个名为“HTTPS”的额外服务器变量
if( isset($_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off' ) { echo 'HTTPS'; } else { echo 'HTTP'; }