PHP Difference between Curl and HttpRequest(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)
我有两种方法
- 卷曲 (http://us.php.net/manual/en/book.curl.php)
- PHP HTTP 使用 HTTPRequest (http://us.php.net/手册/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 区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Curl 和 HttpRequest 的 PHP 区别


基础教程推荐
- PHP 守护进程/worker 环境 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- HTTP 与 FTP 上传 2021-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- 使用 PDO 转义列名 2021-01-01