Friday, June 1, 2012

Simple Way to Make HTTP Request With PHP

PHP is surprisingly lacking in built-in HTTP Request capabilities. To enable this, external libraries or modules are needed.

However, one simple way to do this if only GET requests are needed is this:

$content = file_get_contents("http://www.google.com");

It's simple, doesn't even follow redirects, but gets the job done if your needs are simple.

No comments:

Post a Comment