开发者

Is the PHP CURL api cleaner/faster/better than using streams for HTTP/HTTPS access?

开发者 https://www.devze.com 2023-03-06 04:02 出处:网络
I currently use pretty exclusively the PHP stream context functionality (see http://us2.php.net/m开发者_如何学JAVAanual/en/function.stream-context-create.php) to access HTTP resources and I\'ve been a

I currently use pretty exclusively the PHP stream context functionality (see http://us2.php.net/m开发者_如何学JAVAanual/en/function.stream-context-create.php) to access HTTP resources and I've been able to successfully use it to do PUTs, DELETEs, POSTs, manage cookies and do just about everything I've needed to do. I originally started using it because I had SSL issues with earlier Debian PHP cURL builds (there was an OpenSSL double-initialization issue within the Apache process that errored out when trying to access SSL urls): those are probably fixed now but I've not had occasion to go back.

In discussions with a friend he contended that the cURL api is faster/better so I wanted to ask: is there any definite experience/knowledge about which option is superior, and in what ways?


Streams are pretty neat in my experience. You probably know it already, but here's a post on streams with a twist in case not:

http://fabien.potencier.org/article/44/php-iterators-and-streams-are-awesome

Curl is nice and fast, and simple; but I honestly wouldn't prefer one or the other for performance reasons. I've never measured but I doubt it makes that much of a difference in comparison with the overhead of doing a remote request in the first place.


In regards to performance, cURL wins by a lot consistently. I won't deny that it's harder to use and it might not matter for general use, but the difference was pretty dramatic and I thought it was worth pointing out.

0

精彩评论

暂无评论...
验证码 换一张
取 消