我一直试图让我们知道php中的exec()命令是否成功执行,因此我可以相应地回显某些消息. 我尝试了以下代码,但问题是exec()是否成功运行,是否总是echo "PDF not created"并且从不回显成功创建的pdf.请让我知道如何执行exec()的执行检查,以便我可以相应地回显消息 谢谢,
I have been trying to let know know if the exec() command in php executes successfully or not so i can echo certain messages accordingly. I tried the following piece of code but the problem with it is that whether exec() runs successfully or not it always echo "PDF not created" and never echo pdf created successfully. Kindly let me know how can i perform the check on the execution of exec() so i can echo messages accordingly Thanks,
<?php if (exec('C://abc//wkhtmltopdf home.html sample.pdf')) echo "PDF Created Successfully"; else echo "PDF not created"; ?>推荐答案
根据PHP的 exec quickref ,您可以传递指针以获取命令的输出和状态.
According to PHP's exec quickref, you can pass pointers in to get the output and status of the command.
<?php exec('C://abc//wkhtmltopdf home.html sample.pdf', $output, $return); // Return will return non-zero upon an error if (!$return) { echo "PDF Created Successfully"; } else { echo "PDF not created"; } ?>如果要枚举可能的错误,可以在 hiteksoftware
If you want to enumerate the possible errors, you can find the codes over at hiteksoftware
更多推荐
检查exec()是否成功运行
发布评论