我试图用shell_exec执行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是否存在?
提前致谢
答案 0 :(得分:0)
操作系统并不重要。如果shell_exec
php.ini
,您应该能够使用{{1}}