(Yaf >=1.0.0)
Yaf_Response_Abstract::setHeader — Set an HTTP response header
$name,$value,$replace = false,$response_code = 0Set an HTTP response header.
Nota:
This method is only fully implemented in the Yaf_Response_Http subclass. In the abstract class it is a stub.
nameThe header name.
valueThe header value.
replaceWhether to replace any existing header with the same name. If false, the new value is appended to the existing one, separated by a comma. Note that, although the declared default is false, the current implementation replaces the existing header when this parameter is omitted.
response_codeIf non-zero, the HTTP response code to set on the response.
Example #1 Yaf_Response_Abstract::setHeader() example
<?php
class IndexController extends Yaf_Controller_Abstract
{
public function indexAction()
{
$response = $this->getResponse();
$response->setHeader("Content-Type", "application/json");
/* send a 401 and ask for credentials */
$response->setHeader("WWW-Authenticate", 'Basic realm="Member Area"', true, 401);
}
}
?>