php8.5
Home/ Manual/ yaf / yaf_response_abstract/ Yaf_Response_Abstract::setAllHeaders

Yaf_Response_Abstract::setAllHeaders

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Set all HTTP response headers

Description

Yaf_Response_Abstract::setAllHeaders(array $headers): bool

Set all HTTP response headers at once.

Note

This method is only fully implemented in the Yaf_Response_Http subclass. In the abstract class it is a stub.

Parameters

headers

An array of header name/value pairs. Any existing header with the same name is replaced.

Return Values

Returns true.

Examples

Yaf_Response_Abstract::setAllHeaders example

php
<?php
class IndexController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        $this->getResponse()->setAllHeaders(array(
            "Content-Type"  => "application/json; charset=utf-8",
            "Cache-Control" => "no-cache",
            "X-Request-Id"  => "7f3c2d91",
        ));
    }
}
?>

See Also

  • Yaf_Response_Abstract::setHeader
  • Yaf_Response_Abstract::getHeader
  • Yaf_Response_Abstract::clearHeaders

Source: reference/yaf/yaf_response_abstract/setallheaders.xml · from the official PHP manual (php/doc-en)