The function passthru()
is good when the output contains binary data as the function outputs the raw output. However, the documentation for the function shell_exec()
does not say whether the data returned is binary safe (=raw).
So, my question here is that does shell_exec()
return the raw output? Or do I need to use ob_start()
, ob_get_contents()
and ob_end_clean()
with passthru()
to get the raw output?
It returns a string with the data written to the standard output. Strings in PHP are binary safe; they can contain \\0
characters.
Such characters will be included in the result of shell_exec()
if the executed command resulted in those characters being written. What you do with that is up to you.
Output buffering is irrelevant here; shell_exec()
doesn't output anything to the client, it only returns a string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.