I have the following code in PHP to convert a .doc to pdf using libreoffice:
exec('libreoffice --headless --convert-to pdf sample.doc',$output,$return);
print_r($return);
This prints: 0
meaning success and converted file is also available
However, when I run:
exec('libreoffice --headless --convert-to pdf sample_not_there.doc',$output,$return);
print_r($return);
where sample_not_there.doc does not exist, it still prints 0
and the converted file obviously is not available too.
I want to know if the command was successfully executed or not everytime I run it. Is there a defined way to do it?