thinkphp icon indicating copy to clipboard operation
thinkphp copied to clipboard

IS_CLI常量在某些环境中不正确

Open hoist1999 opened this issue 8 years ago • 2 comments

我的Mac osx中,php在命令行下启动服务器php -s localhost:9999这样,然后在ThinkPHP中,IS_CLI判断不出是命令行。我仔细查询了一下。

ThinkPHP.class.php这个文件中, define('IS_CLI',PHP_SAPI=='cli'? 1 : 0); 是这样判断的,而我机器上PHP_SAPI的值是cli_server。请问这是一个bug吗?能修复一下吗?

hoist1999 avatar Mar 24 '17 08:03 hoist1999

php -s localhost:9999

在php http server模式下,已经不是cli模式了,走的还是的http请求,所以分析成http模式更准确

vus520 avatar Apr 10 '17 01:04 vus520

cli模式运行是:

$ php index.php 

Jayin avatar Apr 10 '17 01:04 Jayin