exec("unoconv -f pdf test.docx 2>&1",$error_array,$code);
if($code!=0)
Log::info('unoconv2文件转换失败:'.json_encode($error));
return false;
return true;
上面exec中的编码 exec(" 你的执行操作 2>&1",返回的报错信息【数组格式】,是否错误编码(0无错误,1有错误))
及当 $code 为1时,$error_array 中便会有错误返回,此时我们只需打印出来,就可知道错误原因。
当 $code 为0时,$error_array 就会返回一个空数组
2>&1 : 在linux 中表达的涵义是 将错误重定向到标准输出,错误和标准输出都通过管道传给下个命令