Home >Backend Development >PHP Problem >How to execute shell in php

How to execute shell in php

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-09-29 10:47:534309browse

How to execute shell in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn