Explain the difference between shell_exec() and exec()
Explain the difference between shell_exec() and exec()
Certainly! Here's a detailed explanation of the difference between shell_exec()
and exec()
in PHP:
shell_exec()
shell_exec()
is used to execute a command via the shell and return the complete output as a string.NULL
.$output = shell_exec('ls -l');
echo "<pre>$output</pre>";
In this example, the ls -l
command lists the files in the current directory in long format, and the output is captured and displayed.
exec()
exec()
is used to execute a command via the shell, but it provides more control over the output and return status.middle
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào