What is different between exec(), shell_exec, system() and passthru() functions in PHP?

php

Solution

- `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.

Problem

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.

Original source

Related problems