时时商务社区

标题: 深入file_get_contents与curl函数的详解 [打印本页]

作者: 新格网络    时间: 2018-2-14 08:16

            有些主机服务商把php的allow_url_fopen选项是关闭了,就是没法直接使用file_get_contents来获取远程web页面的内容。那就是可以使用另外一个函数curl。
下面是file_get_contents和curl两个函数同样功能的不同写法
file_get_contents函数的使用示例:
[U]复制代码[/U] 代码如下:
换成curl函数的使用示例:
[U]复制代码[/U] 代码如下:
利用function_exists函数来判断php是否支持一个函数可以轻松写出下面函数
[U]复制代码[/U] 代码如下:
其实上面的这个函数还有待商榷,如果你的主机服务商把file_get_contents和curl都关闭了,上面的函数就会出现错误。
            
            
您可能感兴趣的文章:
  • php中使用Curl、socket、file_get_contents三种方法POST提交数据
  • 比file_get_contents稳定的curl_get_contents分享
  • 探讨file_get_contents与curl效率及稳定性的分析
  • php采用file_get_contents代替使用curl实例
  • php中file_get_contents与curl性能比较分析
  • PHP CURL或file_get_contents获取网页标题的代码及两者效率的稳定性问题
  • php基于curl重写file_get_contents函数实例
  • PHP curl 或 file_get_contents 获取需要授权页面的方法
            




    欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2