PHP exec() vs system() vs passthru()

前端 未结 5 1115
别那么骄傲
别那么骄傲 2020-11-22 10:34

What are the differences?

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

PHP.net says tha

5条回答
  •  闹比i
    闹比i (楼主)
    2020-11-22 10:55

    If you're running your PHP script from the command-line, passthru() has one large benefit. It will let you execute scripts/programs such as vim, dialog, etc, letting those programs handle control and returning to your script only when they are done.

    If you use system() or exec() to execute those scripts/programs, it simply won't work.

    Gotcha: For some reason, you can't execute less with passthru() in PHP.

提交回复
热议问题