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

查看:31
本文介绍了PHP exec() vs system() vs 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 命令,也许还可以自己处理输出.
  • system() 用于执行system 命令并立即显示输出 - 大概是文本.
  • passthru() 用于执行您希望原始返回的系统命令 - 大概是二进制的东西.

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

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

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

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