使用curl获取文件内容的函数。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用curl获取文件内容的函数。相关的知识,希望对你有一定的参考价值。

A handy function to get the contents of a file with curl. Accepts $_path as a parameter.
  1. function file_content($_path) {
  2. $ch = curl_init();
  3. curl_setopt($ch, CURLOPT_HEADER, 0);
  4. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
  5. curl_setopt($ch, CURLOPT_URL, $_path);
  6. $data = curl_exec($ch);
  7. curl_close($ch);
  8. return $data;
  9. }

以上是关于使用curl获取文件内容的函数。的主要内容,如果未能解决你的问题,请参考以下文章