简体   繁体   中英

PHP curl_setopt() CURLOPT_PROGRESSFUNCTION

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.

This is how the callback looks in C:

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

Probably in PHP it should look like

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

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

You get a full example on the curl website at:

http://curl.haxx.se/libcurl/c/curlgtk.html

More complete PHP answer here: cURL Download Progress in PHP not working?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM