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
It really all comes down to how you want to handle output that the command might return and whether you want your PHP script to wait for the callee program to finish or not.
exec
executes a command and passes output to the caller (or returns it in an optional variable).
passthru
is similar to the exec()
function in that it executes a command . This function should be used in place of exec()
or system()
when the output from the Unix command is binary data which needs to be passed directly back to the browser.
system
executes an external program and displays the output, but only the last line.
If you need to execute a command and have all the data from the command passed directly back without any interference, use the passthru()
function.