php - If page load time takes too long
Get the solution ↓↓↓I have a curl script that I would like to wrap in an if condition to proceed anyway if the page isnt loading. Is it possible to check page load time > if taking too long > proceed anyway?
if(pageLoad != TooMuchTime {
//Curl script to some url
} else {
//Took to long to get a responce
}
The reason I do this is because I use a curl request as part of an install script (to track installs) the curl call is to a php file which inserts data to the database. If for any reason (network congestion, site down, ect.) the page doesn't load I want the user to still be able to install the product.
Answer
Solution:
Curl offers options to achieve the desired action, There is no need for if conditions.
CURLOPT_CONNECTTIMEOUT
- The number of seconds to wait while trying to connect. Use 0 to wait indefinitely.CURLOPT_TIMEOUT
- The maximum number of seconds to allow cURL functions to execute.
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 400); //timeout in seconds
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: warning: a non-numeric value encountered in
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.