preload
0 Comments | Feb 03, 2012

Sending an HTTP Request in PHP without cURL

Estimated Time To Read This: 2 – 3 minutes      


Most people who want to send page requests from PHP use the cURL library, but making sure that the cURL library is installed on the server is not always possible. You don’t need cURL to make a page request, in fact, in some cases it is just easier to use the built in functionality of PHP.

The following code is an example of a very simple page with a single text input and a PHP script that generates a valid HTTP request, sends it to the URL that the user entered, and reads the HTTP standard response code generated by the server that handled the request.

Obviously this is about as simple as you can get, with a little extra code you can read back the entire page response, or add get and post variables to your request. Everything that you can do with cURL, you can also do without it.


Tags:, , , , ,





Related Articles


Leave a Reply

* Required
** Your Email is never shared