Curl 和 HttpRequest 的 PHP 区别

编程入门 行业动态 更新时间:2024-10-18 23:31:30
本文介绍了Curl 和 HttpRequest 的 PHP 区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要对服务器执行 RAW POST(PUT a $var)请求,并将该页面的结果作为字符串接受.还需要添加自定义的HTTP头信息(比如x-example-info:2342342)

I have a need to do RAW POST (PUT a $var) requests to a server, and accept the results from that page as a string. Also need to add custom HTTP header information (like x-example-info: 2342342)

我有两种方法

  • 卷曲 (us.php/manual/en/book.curl.php)
  • PHP HTTP 使用 HTTPRequest (us.php/手册/en/book.http.php)

两者有什么区别?什么更瘦?快点?两者在我看来几乎相同...

What are the differences between the two? what's more lean? faster? Both seem pretty much the same to me...

推荐答案

Curl 与 PHP 捆绑,HTTPRequest 是单独的 PECL 扩展.

Curl is bundled with PHP, HTTPRequest is a separate PECL extension.

因此,CURL 更有可能安装在您的目标平台上,这几乎是大多数项目的决定因素.如果您打算只在您个人有能力安装 PECL 扩展的服务器上安装您的软件,我只会考虑使用 HTTPRequest;如果您的客户自己安装,安装 PECL 扩展通常是不可能的.

As such, it's much more likely that CURL will be installed on your target platform, which is pretty much the deciding factor for most projects. I'd only consider using HTTPRequest if you plan to only ever install your software on servers you personally have the ability to install PECL extensions on; if your clients will be doing their own installations, installing PECL extensions is usually out of the question.

这个页面 似乎暗示 HTTPRequest 在幕后使用了 CURL反正.不过,听起来它可能会为 curl_multi_*() 提供一个稍微优雅的界面.

This page seems to suggest that HTTPRequest uses CURL under the hood anyway. Sounds like it might offer a slightly more elegant interface to curl_multi_*(), though.

更多推荐

Curl 和 HttpRequest 的 PHP 区别

本文发布于:2023-06-06 00:34:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/531184.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区别   Curl   HttpRequest   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!