Home >Backend Development >PHP Tutorial >解析php中如何直接执行SHELL_PHP

解析php中如何直接执行SHELL_PHP

WBOY
WBOYOriginal
2016-06-01 12:04:21992browse

$message=shell_exec("sudo /usr/local/webserver/nginx/sbin/nginx -t 2>&1");
echo "运行结果:".$message."
";
 
上面的语句可以直接在PHP中执行SHELL语句

如果有返回值 那么其中的 2>&1 是必须的  他会重定向输出strerr 转到strout 输出!

否则返回结果会为空!

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