What are the differences between shell_exec and exec in PHP?

The main difference between `shell_exec` and `exec` in PHP is that `shell_exec` returns the output of the command as a string, while `exec` returns the last line of the output. Additionally, `shell_exec` is used to execute a command in the shell and return its output, while `exec` is used to execute a command and return the last line of the output.

// Using shell_exec
$output = shell_exec('ls -la');
echo $output;

// Using exec
exec('ls -la', $output);
echo implode("\n", $output);