file_get_contents获取远程网页内容函数
由于某种原因把php的allow_url_fopen选项是关闭了,就是没法直接使用file_get_contents来获取远程web页面的内容,那就是可以使用另外一个函数curl.
无限file_get_contents获取远程网页内容函数,代码如下:
- function vita_get_url_content($url) {
 - if(function_exists('file_get_contents')) {
 - $file_contents = file_get_contents($url);
 - } else {//开源代码phpfensi.com
 - $ch = curl_init();
 - $timeout = 5;
 - curl_setopt ($ch, curlopt_url, $url);
 - curl_setopt ($ch, curlopt_returntransfer, 1);
 - curl_setopt ($ch, curlopt_connecttimeout, $timeout);
 - $file_contents = curl_exec($ch);
 - curl_close($ch);
 - }
 - return $file_contents;
 - }
 
由于某种原因把php的allow_url_fopen选项是关闭了,就是没法直接使用file_get_contents来获取远程web页面的内容,那就是可以使用另外一个函数curl.