Curl 和 HttpRequest 的 PHP 区别 [英] PHP Difference between Curl and HttpRequest

查看:35
本文介绍了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)

我有两种方法

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

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 区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆