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

Boolean Tester Methods

Once a Zend_Http_Response object is instantiated, it provides several methods that can be used to test the type of the response. These all return Boolean TRUE or FALSE:

  • isSuccessful(): Whether the request was successful or not. Returns TRUE for HTTP 1xx and 2xx response codes

  • isError(): Whether the response code implies an error or not. Returns TRUE for HTTP 4xx (client errors) and 5xx (server errors) response codes

  • isRedirect(): Whether the response is a redirection response or not. Returns TRUE for HTTP 3xx response codes

Example 503. Using the isError() method to validate a response

if ($response->isError()) {
"Error transmitting data.\n"
echo "Server reply was: " $response->getStatus() .
" " $response->getMessage() . "\n";
// .. process the response here...

Zend Framework