What are the advantages and disadvantages of using exec versus passthru for executing commands in PHP?

When executing commands in PHP, the `exec` function is generally preferred over `passthru` due to its greater control over the output and return values of the command. `exec` allows for capturing the output of the command into a variable, while `passthru` directly outputs the command's result to the browser. However, `exec` may be disabled on some servers for security reasons, in which case `passthru` can be used as an alternative.

// Using exec function to execute a command and capture its output
$output = [];
$return_var = 0;
exec('ls -la', $output, $return_var);

// Output the result
foreach ($output as $line) {
    echo $line . "<br>";
}