php curl 10秒超时 [英] php curl 10 seconds timeout
本文介绍了php curl 10秒超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
代码:
<?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){
echocURL错误($ curl_errno):$ curl_error\\\
;
}
?>
我想在浏览器上等待10秒钟。 10秒后,它将在浏览器上显示错误消息。但是,当我刷新我的网页,它只加载3秒。如何在浏览器上加载10秒?
解决方案
$ b
你应该使用 sleep(10)
;
等待浏览器10秒
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?
解决方案
Well, its simple.
you should use sleep(10)
;
to wait browser for 10 sec
这篇关于php curl 10秒超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文