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;
}

你可能感兴趣的:(content)