php-cli甚至存在于命令行选项中吗


Does php-cli even exist in command line options?

我试图用shell_exec通过php执行一个php文件,这是代码:

$ex="php -f ".rtrim(dirname(__FILE__))."/sendmail.php";
if(substr(php_uname(), 0, 7) == "Windows")
    pclose(popen("start /B ".$ex,"r")); 
else
    shell_exec($ex." > /dev/null 2>/dev/null &");

问题是它在我的服务器上不起作用(我甚至尝试过不使用-f),但这没关系:

$ex="php-cli ".rtrim(dirname(__FILE__))."/sendmail.php";
if(substr(php_uname(), 0, 7) == "Windows")
    pclose(popen("start /B ".$ex,"r"));
else
    shell_exec($ex." > /dev/null 2> /dev/null &");

有人能告诉我为什么它有效吗?php-cli是否存在
提前感谢

操作系统无关紧要。如果php.ini 中未禁用shell_exec,您应该能够使用它