PHP curl_setopt()CURLOPT_PROGRESSFUNCTION [英] PHP curl_setopt() CURLOPT_PROGRESSFUNCTION

查看:488
本文介绍了PHP curl_setopt()CURLOPT_PROGRESSFUNCTION的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 curl_setopt()文档中看到您可以设置一个回调函数来显示curl_exec的进度。关于如何使用回调函数没有太多说明。有人知道吗?我只想输出已下载到STDOUT的文件的百分比。感谢。

i see in the curl_setopt() documentation that you can set a callback function to display the progress of a curl_exec. There's not much said on how the callback function is used. Does anyone know? I'd just like to output the percentage of the file which has been downloaded to STDOUT. Thanks.

推荐答案

这是回调在C中的样子:

This is how the callback looks in C:

typedef int (*curl_progress_callback)(void *clientp,
                                      double dltotal,
                                      double dlnow,
                                      double ultotal,
                                      double ulnow);

可能在PHP中它应该像

Probably in PHP it should look like

curl_progress_callback($clientp, $dltotal, $dlnow, $ultotal, $ulnow)


b $ b

我假设dl代表下载,ul代表上传。

I suppose that dl stands for download and ul for upload.

这篇关于PHP curl_setopt()CURLOPT_PROGRESSFUNCTION的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆