发布于 4年前

PHP报错“Undefined index: REQUEST_SCHEME”

在本地开发环境$_SERVER['REQUEST_SCHEME']正常,传到服务器上报错“Undefined index: REQUEST_SCHEME”,且打印结果为空。

服务器环境为 Linux Nginx

解决方案:

可以通过变量$_server['server_protocol']获取使用的协议:

$protocol = strpos(strtolower($_server['server_protocol']),'https')  === false ? 'http' : 'https';
©2020 edoou.com   京ICP备16001874号-3