deviantPsyche Posted January 7, 2010 Share Posted January 7, 2010 I'm trying to figure out a way to get page loading time while the page is still loading. What I want to do is to stop script execution if the amount of loading time is for example > 10 seconds during page load. I'm using curl to load my pages. So far, the only way I can see this happening is to use CURLOPT_WRITEFUNCTION to call another function within curl. But the problem with it, is that it still not able to pull out live time elapsed from it. If I use curl_getinfo within that function I'm only able to print out curl_getinfo['total_time'] after the whole page loads. Is there a way to get the page loading time before the whole page loads? Link to comment https://forums.phpfreaks.com/topic/187636-curl-and-page-loading-time-question/ Share on other sites More sharing options...
Minase Posted January 7, 2010 Share Posted January 7, 2010 i think with php and ajax you can achieve this set the run time for the script @ 10 seconds Link to comment https://forums.phpfreaks.com/topic/187636-curl-and-page-loading-time-question/#findComment-990627 Share on other sites More sharing options...
deviantPsyche Posted January 7, 2010 Author Share Posted January 7, 2010 yeah I actually found a much easier way to end the script execution time by simply setting CURLOPT_CONNECTTIMEOUT to timeout that I want, the problem is that I actually need to call a function on timeout so that I can do something else with the script. Is it possible to somehow catch when CURLOPT_CONNECTTIMEOUT is true so that I can return something else and then call another function? Link to comment https://forums.phpfreaks.com/topic/187636-curl-and-page-loading-time-question/#findComment-990658 Share on other sites More sharing options...
deviantPsyche Posted January 7, 2010 Author Share Posted January 7, 2010 figured it out basically: $page = curl_load("http://www.google.com",""); if ($page==""){ //means CURLOPT_CONNECTTIMEOUT is true echo "connection timed out!<br />"; } else { echo $page; } easy as that heh. Link to comment https://forums.phpfreaks.com/topic/187636-curl-and-page-loading-time-question/#findComment-990686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.