Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何隐藏从shell_exec()启动的Linux命令的输出_Php - Fatal编程技术网

Php 如何隐藏从shell_exec()启动的Linux命令的输出

Php 如何隐藏从shell_exec()启动的Linux命令的输出,php,Php,大家好,这是我的密码 <?php $res = shell_exec('curl http://www.example.com'); 我什么都不想看到我该怎么办???您可以使用输出缓冲 ob_start(); $res = shell_exec('curl http://www.example.com'); ob_end_clean(); 您可以看到该输出,因为curl将其当前进度输出到STDERR 如果要忽略它,可以通过重定向来解决此问题: $res = shell_exec

大家好,这是我的密码

<?php
  $res = shell_exec('curl  http://www.example.com');

我什么都不想看到我该怎么办???

您可以使用输出缓冲

ob_start();
$res = shell_exec('curl  http://www.example.com');
ob_end_clean();

您可以看到该输出,因为curl将其当前进度输出到STDERR

如果要忽略它,可以通过重定向来解决此问题:

$res = shell_exec('curl  http://www.example.com 2>/dev/null');
或者,在shell级别:

$ php script.php 2>/dev/null

你总是给curl打电话吗?如果你应该用这种方式,我必须用这种方式,谢谢这是最好的方式
$ php script.php 2>/dev/null