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

How to execute shell in php

爱喝马黛茶的安东尼
Release: 2023-02-25 14:48:02
Original
4269 people have browsed it

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");
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template