News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

David Sklar's Blog:
Parsing Reasonably-sized HTTP Responses
January 30, 2006 @ 07:31:01

David Sklar has a new post today with his solution to a common problem in PHP scripts that interact over HTTP.

From with a PHP program, I'd like to make an HTTP request and use the response body in my program. What could be simpler? PHP has a zillion ways to do it, not limited to: file_get_contents(), fopen() and fread(), fsockopen(), curl, and PEAR HTTP_Request.

One additional requirement that makes this slightly more interesting: I don't want to waste any memory on a response body that's too big. If I slurp in a giant request body, I might run over my memory_limit.

Here's what I came up with to solve this problem...

His solution uses the curl functionality inside of a class, making it a simple matter of making an object and issuing a get() call to reach out and grab that resource via a HTTP connection...

0 comments voice your opinion now!
parse http response curl function get class parse http response curl function get class


blog comments powered by Disqus

Similar Posts

Hiveminds Magazine: Using numbers in PHP function names

Ken Guest's Blog: A response to "Better Postal/Zip Code Validation Method for CakePHP 1.2"

Ian Selby's Blog: Create a REST API with PHP

Ilia Alshanetsky's Blog: Google Docs Backup Script

Matthew Weier O'Phinney: On HTTP, Middleware, and PSR-7


Community Events

Don't see your event here?
Let us know!


library laravel5 api threedevsandamaybe version interview voicesoftheelephpant podcast extension laravel release language unittest series security framework opinion community symfony introduction

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework