Home >Backend Development >PHP Tutorial >php file_get_contents function_PHP tutorial
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