Explain the difference between shell_exec() and exec() Technology Community › Category: PHP › Explain the difference between shell_exec() and exec() 0 Vote Up Vote Down VietMX Staff asked 4 years ago shell_exec returns all of the output stream as a string. exec returns the last line of the output by default, but can provide all output as an array specified as the second parameter.