Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Using Zend_Http_Client

The class constructor optionally accepts a URL as its first parameter (can be either a string or a Zend_Uri_Http object), and an array or Zend_Config object containing configuration options. Both can be left out, and set later using the setUri() and setConfig() methods.

Example 473. Instantiating a Zend_Http_Client Object

= new Zend_Http_Client('', array(
'maxredirects' => 0,
'timeout'      => 30));

// This is actually exactly the same:
$client = new Zend_Http_Client();
'maxredirects' => 0,
'timeout'      => 30));

// You can also use a Zend_Config object to set the client's configuration
$config = new Zend_Config_Ini('httpclient.ini''secure');


Zend_Http_Client uses Zend_Uri_Http to validate URLs. This means that some special characters like the pipe symbol ('|') or the caret symbol ('^') will not be accepted in the URL by default. This can be modified by setting the 'allow_unwise' option of Zend_Uri to 'TRUE'. See this section for more information.

Zend Framework