dongzhao4036 2015-02-05 22:12
浏览 36
已采纳

为什么file_get_contents()似乎与curl_exec()具有相同的访问权限?

I am downloading favicons using PHP and I spent a while troubleshooting before I noticed that curl_exec appears to work for some sites while file_get_contents does not.

For example here is the response from http://www.hellmanns.com/favicon.ico

file_get_contents

Warning: file_get_contents(http://hellmanns.com/favicon.ico): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden in /home/arcmarks/public_html/arcmarks/source/class.FaviconFinder.php on line 44

curl_exec

h( e?Câ¬^ÏÉÌŒ$ B#(ÌlcYfƒy9C¥D;üès¨H8§¥§‹&5é¨QÛœJ©O5Öžfå§LíáÛÜ߸n Ü®Œa~ †}…l “‘±“o}þþþ¥FHòòÞïïï/Á±mžç¿~L"-‚y¾i'öá̳²¶£A%«§¬?ùíÜ©„i­²~Âh*®^?ÖáµÅÅ™ØezU[¢<4¡-5;/ïÀöæØaéìÐ̆cN ,;U@N㽧õðî‰Õ¨îѹk_jÖšmîÙÌáÜÝ[æ™-ì·D¡?-s­wE‹# õ¹„$0”6&ï²1Ú¦Žž#”+$§HR¢@3€,3Â@üÿÿþÿÿP:H€ô¯VüáBâ™?„j W~±¦ª†ôòóaQ ŸE7Ç|@F2?G2?åóãäå¸~Q p,KEv(Cud).#lUH4mkr$gj[ahVf9&2Se/@ZLwPYiF0qOG?y>QbJx+cIMDzW!-]*'t5B;<^%T6 _XsR=` :n"A7831o N ÿÿÿÿÿÿÿÿ€Àÿÿÿÿÿÿÿÿ

  • 写回答

2条回答 默认 最新

  • doushi1996 2016-03-15 21:08
    关注

    curl_exec is based upon and entire project that is used in many different languages see here:

    Why doesn't file_get_contents() appear to have the same access as curl_exec()?

    Hence it has much more support.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么