PHP exec()与system()与passthru() [英] PHP exec() vs system() vs passthru()

查看:79
本文介绍了PHP exec()与system()与passthru()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么区别?

每个功能是否有特定情况或原因?如果可以,您能举一些例子吗?

Is there a specific situation or reason for each function? If yes, can you give some examples of those situations?

PHP.net说,它们用于执行外部程序. 参见参考 从我看到的示例中,我看不出任何明显的区别.

PHP.net says that they are used to execute external programs. see reference From the examples I see, I don't see any obvious difference.

如果我仅运行脚本(bash或python),那么建议我使用哪个功能?

If I were to simply run a script (bash or python), which function do you recommend me to use?

推荐答案

它们的用途略有不同.

  • exec() 用于调用系统命令,也许用于处理您自己输出.
  • system() 用于执行系统命令并立即显示输出-大概是文字.
  • passthru() 用于执行您希望原始的系统命令返回-大概是二进制文件.

无论如何,我建议您不要使用其中任何一个.它们都产生高度不可移植的代码.

Regardless, I suggest you not use any of them. They all produce highly unportable code.

这篇关于PHP exec()与system()与passthru()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆