<?php if(!isset($_GET['foo'])){ //Client $ch=curl_init('http://example.com/'); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLOPT_NOSIGNAL,1);//注意,毫秒超时一定要设置这个 curl_setopt($ch,CURLOPT_TIMEOUT_MS,200);//超时毫秒,cURL7.16.2中被加入。从PHP5.2.3起可使用 $data=curl_exec($ch); $curl_errno=curl_errno($ch); $curl_error=curl_error($ch); curl_close($ch); if($curl_errno>0){ echo"cURLError($curl_errno):$curl_errorn"; }else{ echo"Datareceived:$datan"; } }else{ //Server sleep(10); echo"Done."; } ?>
转载于:https://my.oschina.net/u/2416644/blog/784914