How does the choice between using exec() and shell_exec() impact the execution of external commands in PHP scripts?
The choice between using exec() and shell_exec() in PHP scripts impacts the execution of external commands in terms of how the output is handled. exec() is used to execute a command and return the last line of the command output, while shell_exec() is used to execute a command and return the complete output as a string. Depending on the specific requirements of the script, one function may be more suitable than the other.
// Using exec() to execute a command and return the last line of output
$output = exec('ls -l');
echo $output;