1

Code:

<?php
$directory = 'http://www.google1.com';  
$returntransfer = true;
$connecttimeout = 10;
$timeout = 10; 

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $directory);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, $returntransfer);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $connecttimeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);

$execute = curl_exec($ch);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);

if ($curl_errno > 0) {
    echo "cURL Error ($curl_errno): $curl_error\n";
}
?>

I want to wait 10 seconds on browser. After 10 seconds, it will show the error messages on the browser. However, when I refresh my web page, it only load 3 seconds. How should I do in order to load 10 seconds on the browser?

2
  • 1
    "I want to wait 10 seconds on browser. " - sleep(10); (ahah.) Commented Jan 6, 2015 at 4:02
  • If you want simulate the timeout: $directory = 'http://www.google.com'; and add curl_setopt ($ch, CURLOPT_PORT , 81); Commented Jan 6, 2015 at 4:11

2 Answers 2

2

Well, its simple.

you should use sleep(10);

to wait browser for 10 sec

Sign up to request clarification or add additional context in comments.

Comments

0

http://google1.com doesn't resolve for me. After the query gets stored locally, the DNS request will timeout immediately no matter what you set $timeout to be.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.