检查exec()是否成功运行

编程入门 行业动态 更新时间:2024-10-27 16:33:52
本文介绍了检查exec()是否成功运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我一直试图让我们知道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()是否成功运行

本文发布于:2023-11-07 15:03:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566767.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:exec

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!