开发者

CURL vs fopen vs fsocketopen?

开发者 https://www.devze.com 2022-12-27 14:11 出处:网络
I would write a WordPress plugin to parse all image source and check it\'s broken link or not. My idea is :

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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消