Anybody please tell me. I want know the different between the exec()
, shell_exec
, system()
and passthru()
function?
I search from php.net unable to get the answers I need.
Anybody please tell me. I want know the different between the exec()
, shell_exec
, system()
and passthru()
function?
I search from php.net unable to get the answers I need.
exec
only returns the last line of the generated output.shell_exec
returns the full output of the command, when the command finished running. system
immediately shows all output, and is used to show text. passthru
also returns output immediately, but is used for binary data. passthru
displays raw data. With both exec
and shell_exec
it is possible to handle the output yourself, while system
and passthru
won't let you customize it and immediately display the output.
A more detailed comparison can be found here.
passthru is used for returning binary data instead of ascii. A typical example is where an image manipulation program is returning an image instead of text data.
See PHP - exec() vs system() vs passthru() for more info
Also see php shell_exec() vs exec().