PHP 常量 PHP_SAPI 具有和 php_sapi_name() 相同的值。

1 define('IS_CGI',(0 === strpos(PHP_SAPI,'cgi') || false !== strpos(PHP_SAPI,'fcgi')) ? 1 : 0 );
2 define('IS_WIN',strstr(PHP_OS, 'WIN') ? 1 : 0 );
3 define('IS_CLI',PHP_SAPI=='cli'? 1   :   0);

这段代码是ThinkPHP项目里Thinkphp.php文件判断运行环境模式。SAPI:Server Application Programming Interface 服务器端应用编程端口。SAPI提供了一个和外部通信的接口,常见的SAPI有:cgi 、fast-cgi、cli、isapi、apache 模块的 DLL。

 

 

相关文章:

  • 2021-09-07
  • 2022-12-23
  • 2021-12-11
  • 2021-05-19
  • 2021-06-12
  • 2022-01-12
  • 2021-11-05
  • 2021-12-12
猜你喜欢
  • 2021-12-26
  • 2021-10-23
  • 2021-07-03
  • 2021-07-04
  • 2021-08-01
相关资源
相似解决方案