我基本上想使用 shell_exec
检查命令是否成功运行。
简单的功能:
public static function foo()
{
$command = "blabla";
shell_exec($command);
}
编辑,我试过 M 先生的建议是这样的:
foreach($commands as $key => $value)
{
shell_exec($value, $output, $return);
}
我得到这个错误:
Undefined variable: output
最佳答案
尝试使用exec
:
$output = array();//Each line will be assigned to this array if any are generated.
$result1 = exec($command, $output, $return);
if ($return != 0)
{
// error occurred
}
else
{
// success
}
关于Php 检查 shell_exec 命令是否成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39791061/