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测试数据 $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.
查看更多关于file_get_contents获取远程网页内容函数 - php函数的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did30970