php provides us with three functions: system(), exec(), and passthru() to call external commands.
Related recommendations: "php Getting Started Tutorial"
Although these three commands can execute the shell commands of the Linux system, they are actually different:
·system() Outputs and returns the last line of shell results.
·exec() does not output results and returns the last line of shell results. All results can be saved in a returned array.
·passthru() only calls the command and outputs the result of the command directly to the standard output device as is.
Same point: you can get the status code of command execution.
Example:
system("/usr/local/bin/webalizer/webalizer");
The above is the detailed content of How to execute shell in php. For more information, please follow other related articles on the PHP Chinese website!