Home  >  Article  >  Backend Development  >  php file_get_contents function_PHP tutorial

php file_get_contents function_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:00:34790browse

php file_get_contents function,

This function is used to read the contents of the remote server file, which greatly facilitates writing and collecting friends. You can save the remote server file to your own database with a very simple sentence. You say it is simple, but it will not work. Let me give you an example.

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

}

That’s it, the remote content you want is stolen for you, but there is also an ob_get_contents(); function that is the same as the file_get_contents function, but I heard that the effect is better.

/*

$ch =curl_init($url);

ob_start();

curl_exec ($ch);

$retmsg=ob_get_contents();

ob_clean();

ob_end_flush();

curl_close ($ch);

*/

Haha, you will know which one is better after you use it yourself. I will stop here. Please indicate the original reprint on this site: www.111cn.cn


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445524.htmlTechArticlephp file_get_contents function, this function is used to read the contents of remote server files, which greatly facilitates writing and collecting friends , you can save the files on the remote server with just one simple sentence...
Statement:
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