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

前端 未结 5 1120
别那么骄傲
别那么骄傲 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条回答
  •  醉话见心
    2020-11-22 11:02

    They have slightly different purposes.

    • exec() is for calling a system command, and perhaps dealing with the output yourself.
    • system() is for executing a system command and immediately displaying the output - presumably text.
    • passthru() is for executing a system command which you wish the raw return from - presumably something binary.

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

提交回复
热议问题