简体   繁体   English

CURL vs fopen vs fsocketopen吗?

[英]CURL vs fopen vs fsocketopen?

I would write a WordPress plugin to parse all image source and check it's broken link or not. 我会写一个WordPress插件来解析所有图像源,并检查它是否损坏。 My idea is : 我的想法是:

  1. Select all post&page's images by regex from MySQL 通过MySQL从regex选择所有帖子和页面的图像
  2. Navigate the image url and get the response header (404 ,403 error etc) 浏览图片网址并获取响应标头(404、403错误等)
  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? 由于我不需要实际下载二进制文件,因此在性能上,请在CURL,fopen和fsocketopen中进行比较,哪一个是最差的?

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). 更好的选择是使用wse允许您进行HEAD请求的任何功能(仅返回HTTP标头)。 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. 尽管您可以使用fsockopen (我不了解fopen )来做到这一点,但是当cURL已经编写了用于发送请求和解析响应的代码时,这是很多工作。

For an example of how to do a head request using cURL see this answer . 有关如何使用cURL进行头请求的示例, 请参见此答案

And one more question, which method can execute in multi-thread? 还有一个问题,哪种方法可以在多线程中执行?

PHP doesn't have threads PHP没有线程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM