我试图用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真的存在吗?
提前感谢
发布于 2013-06-29 05:07:13
操作系统无关紧要。如果您的php.ini中没有禁用shell_exec,您应该能够使用它
https://stackoverflow.com/questions/17373664
复制相似问题