Yaf_Response_Abstract::getHeader
(Yaf >=1.0.0)
Retrieve an HTTP response header
Description
Retrieve an HTTP response header.
This method is only fully implemented in the Yaf_Response_Http subclass. In the abstract class it is a stub.
Parameters
nameThe header name. If omitted, all headers are returned as an array.
Return Values
The header value as a string, or an array of all headers when the name is omitted. Returns null if the requested header is not set.
Examples
Yaf_Response_Abstract::getHeader example
<?php
class IndexController extends Yaf_Controller_Abstract
{
public function indexAction()
{
$response = $this->getResponse();
$response->setHeader("Content-Type", "application/json");
var_dump($response->getHeader("Content-Type"));
var_dump($response->getHeader()); // all headers
var_dump($response->getHeader("X-Missing"));
}
}
?>The above example will output something similar to:
string(16) "application/json"
array(1) {
["Content-Type"]=>
string(16) "application/json"
}
NULLSee Also
Yaf_Response_Abstract::setHeaderYaf_Response_Abstract::clearHeadersYaf_Response_Abstract::setAllHeaders