且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何确定脚本是从命令行调用的还是作为 cgi 脚本调用的?

更新时间:2023-10-06 13:25:04

根据RFC3875(第 4.1.4 节.),GATEWAY_INTERFACE 环境变量将是检查您是否在 CGI 上下文中运行的权威:

According to the CGI specification in RFC3875 (section 4.1.4.), the GATEWAY_INTERFACE environment variable would be the authoritative thing to check whether you are running in a CGI context:

GATEWAY_INTERFACE 变量必须设置为 CGI 的方言被服务器用来与脚本通信.

4.1.4. GATEWAY_INTERFACE

The GATEWAY_INTERFACE variable MUST be set to the dialect of CGI being used by the server to communicate with the script.