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

Yaf_Response_Abstract::clearHeaders

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Remove all response headers

Description

Yaf_Response_Abstract::clearHeaders(): Yaf_Response_Abstract|false|null

Remove all HTTP response headers that have been set.

Note

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

Parameters Parameters

Return Values

Returns the response object itself on success, or false on failure.

Examples

Yaf_Response_Abstract::clearHeaders example

php
<?php
class IndexController extends Yaf_Controller_Abstract
{
    public function indexAction()
    {
        $response = $this->getResponse();

        $response->setHeader("Content-Type", "application/json");
        $response->clearHeaders();

        var_dump($response->getHeader()); // array(0) { }
    }
}
?>

See Also

  • Yaf_Response_Abstract::setHeader
  • Yaf_Response_Abstract::getHeader
  • Yaf_Response_Abstract::setAllHeaders

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