php 方法筆記 比file_get_contents好

/*比file_get_contents穩定的多!$timeout爲超時時間,單位是秒,默認爲1s。*/
private function curl_get_contents($url,$timeout=1) {
$curlHandle = curl_init();
curl_setopt( $curlHandle, CURLOPT_URL, $url );
curl_setopt( $curlHandle, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt( $curlHandle, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt( $curlHandle, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curlHandle, CURLOPT_TIMEOUT, $timeout );
$result = curl_exec( $curlHandle );
curl_close( $curlHandle );
return $result;
} curl

相關文章
相關標籤/搜索