6.2. Basic GET Requests with Specified HTTP Headers

The Zend_HttpClient constructor creates a Zend_HttpClient instance for sending HTTP requests.

When using Zend_HttpClient on a single URL, in most cases you can supply the URL and relevant headers to the constructor, as in the following examples:

Example 6.2. Creating a Basic Zend_HttpClient

<?php
require_once 'Zend/HttpClient.php';

// Specify the URL and a single header
$http = new Zend_HttpClient('http://example.org', 'Accept: text/html');
?>       

Example 6.3. Sending Multiple Headers

<?php
require_once 'Zend/HttpClient.php';

// Specify the URL and multiple headers
$http = new Zend_HttpClient('http://example.org',
                        array('Accept: text/html', 'Accept-Language: en-us,en;q=0.5'));
?>       

If you wish to use Zend_HttpClient to send requests to multiple URLs, see Section 6.3, “Requesting Multiple Domains”