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