[英]PHP+cURL disable command line progress output
I have a PHP script which connects to a remote server with cURL and download some files. 我有一个PHP脚本,它使用cURL连接到远程服务器并下载一些文件。 I run it thru the command line,
我通过命令行运行它,
php get.php
Whenever it starts downloading data, I get this output: 每当它开始下载数据时,我得到这个输出:
Total % Received % Xferd Average Speed Tim Dload Upload Total Spent Left Speed
100 162k 0 162k 0 0 21732 0 --:--:-- 0:00:07 --:--:-- 36001
How do I disable it? 我该如何禁用它?
From the manual refering to CURLOPT_NOPROGRESS : 从手册中参考CURLOPT_NOPROGRESS :
CURLOPT_NOPROGRESS
CURLOPT_NOPROGRESS
TRUE to disable the progress meter for cURL transfers.
如果为禁用cURL传输的进度表,则为TRUE。
Note: PHP automatically sets this option to TRUE, this should only be changed for debugging purposes.
注意:PHP会自动将此选项设置为TRUE,只应更改此选项以进行调试。
Looks like the progress has been explicitly turned on. 看起来已经明确启用了进度。 Check your code for that option.
检查您的代码以获取该选项。 In any case, if you want to explicitly disable it again,
curl_setopt($curlHandle, CURLOPT_NOPROGRESS, true)
should do the trick. 在任何情况下,如果你想再次明确禁用它,
curl_setopt($curlHandle, CURLOPT_NOPROGRESS, true)
应该可以解决问题。
Update: If you instead do something like exec("curl http://example.com")
you should a) think about what you're doing and b) run curl -s
to disable the progress. 更新:如果您改为执行类似
exec("curl http://example.com")
您应该a)考虑您正在做的事情,并且b)运行curl -s
来禁用进度。 PHP's streams have support for http, so you can just use file_get_contents
, copy
et al. PHP的流支持http,所以你可以使用
file_get_contents
, copy
等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.