当前位置:网站首页>Using exec in PHP to display errors

Using exec in PHP to display errors

2022-06-11 09:50:00 Burn oil to follow the sundial, and live in poverty

exec("unoconv -f pdf test.docx 2>&1",$error_array,$code);
if($code!=0)
   Log::info('unoconv2 File conversion failed :'.json_encode($error));
    return false;

 return true;

above exec Code in exec(" Your execution 2>&1", Returned error message 【 The array format 】, Error code (0 No mistake ,1 Erroneous ))

And when $code by 1 when ,$error_array There will be an error return in , At this point we just need to print out , You can know the cause of the error .

When $code by 0 when ,$error_array Will return an empty array

2>&1 : stay linux The meaning expressed in is   Redirect errors to standard output , Errors and standard output are piped to the next command

原网站

版权声明
本文为[Burn oil to follow the sundial, and live in poverty]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206110930203766.html