CURL vs fopen vs fsocketopen?
I would write a WordPress plugin to parse all image source and check it's broken link or not. My idea is :
- Select all post&page开发者_开发问答's images by regex from MySQL
- Navigate the image url and get the response header (404 ,403 error etc)
- 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
精彩评论