Curl 和 HttpRequest 的 PHP 区别

PHP Difference between Curl and HttpRequest(Curl 和 HttpRequest 的 PHP 区别)
本文介绍了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 区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)