php file_get_contents函数_PHP教程

WBOY
Release: 2016-07-20 11:00:34
Original
776 people have browsed it

php file_get_contents函数,

本函数用来读取远程服务器文件的内容,这样大大的方便写采集朋友了,只要很简单的一句就可以把远程服务器的文件保存到自己的数据库,你说简单不,光说不行了我举个例子看看吧.

function getcontent($url) {
$retmsg =file_get_contents(' http://111cn.cn/index.html ');
return $retmsg;

}

这就么一句,你想要的远程内容就给你偷过来了,不过还有一个与file_get_contents函数相同的ob_get_contents();函数,但听说效果要好了一些.

/*

$ch =curl_init($url);

ob_start();

curl_exec ($ch);

$retmsg=ob_get_contents();

ob_clean();

ob_end_flush();

curl_close ($ch);

*/

呵呵,具体那个好你自己用了才知道了我就说到这里了,本站原创转载请注明: www.111cn.cn


www.bkjia.com true http://www.bkjia.com/PHPjc/445524.html TechArticle php file_get_contents函数, 本函数用来读取远程服务器文件的内容,这样大大的方便写采集朋友了,只要很简单的一句就可以把远程服务器的文件保...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!