侃侃无极
curl代码如下123456789101112131415161718192021222324/** * curl操作 * @param unknown_type $pURL * @param unknown_type $pPostData * @return unknown */ public static function getURLContent($pURL, $pPostData = '') { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $pURL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1); // 连接超时(秒) curl_setopt($ch, CURLOPT_TIMEOUT, 3); // 执行超时(秒) if($pPostData) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $pPostData); } $out_put = curl_exec($ch); curl_close($ch); return $out_put; } 理论是可以设置无限长的时间,但实际操作中不可能这样做,可根据实际情况设置curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1); // 连接超时(秒)curl_setopt($ch, CURLOPT_TIMEOUT, 3); // 执行超时(秒)