soma56 Posted June 18, 2010 Share Posted June 18, 2010 Is anyone familiar echoing text while cURL procesing? It takes a few seconds and would be nice to echo something out to the user to let them know the status. I've tried different things like... <?PHP echo "Please Wait.."; sleep(5); $curl_handle=curl_init(); curl_setopt($curl_handle,CURLOPT_URL, $url); curl_setopt($curl_handle,CURLOPT_CONNECTTIMEOUT,2); curl_setopt($curl_handle,CURLOPT_RETURNTRANSFER,1); curl_setopt($curl_handle, CURLOPT_TIMEOUT, 150); $buffer = curl_exec($curl_handle); curl_close($curl_handle); ?> ...and other variations however the page seems to want to load everything - at once. What I'd like to happen is for the text to echo first and/or prior/while cURL is doing its thing. Link to comment https://forums.phpfreaks.com/topic/205126-echo-while-curl-is-doing-its-thing/ Share on other sites More sharing options...
soma56 Posted June 18, 2010 Author Share Posted June 18, 2010 After doing more research I discovered that one way around this would be to "flush the buffer" or (according to php.net) "This attempts to push current output all the way to the browser with a few caveats. " As a result, this worked effectively to solve my problem: <?PHP echo "Please Wait.." . "<br />". PHP_EOL; ob_flush(); flush(); usleep(50000); ?> Link to comment https://forums.phpfreaks.com/topic/205126-echo-while-curl-is-doing-its-thing/#findComment-1073894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.