douyan8070 2010-04-15 16:32
浏览 51
已采纳

CURL vs fopen vs fsockopen?

I would write a WordPress plugin to parse all image source and check it's broken link or not. My idea is :

  1. Select all post&page's images by regex from MySQL
  2. Navigate the image url and get the response header (404 ,403 error etc)
  3. print a report

Since i don't need actual to download the binary file, so in performance ,compare in CURL , fopen , fsocketopen Which one is worst to use?

And one more question, which method can execute in multi-thread?

  • 写回答

1条回答 默认 最新

  • doushui20090526 2010-04-15 16:52
    关注

    The cost of opening a connection to the remote server makes the performance of the library a fairly moot point. In other words it isn't worth worrying about the performance of the functions.

    A better option would be to use wse whatever function allows you to make HEAD requests (Which only return the HTTP headers). While you can do it with fsockopen (I don't know about fopen), it is a lot of work when cURL has code already written to send the request and parse the response.

    For an example of how to do a head request using cURL see this answer.

    And one more question, which method can execute in multi-thread?

    PHP doesn't have threads

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 wpf界面一直接收PLC给过来的信号,导致UI界面操作起来会卡顿
  • ¥15 init i2c:2 freq:100000[MAIXPY]: find ov2640[MAIXPY]: find ov sensor是main文件哪里有问题吗
  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了