PHP 8.5.10 Released!

Yaf_Response_Abstract::clearBody

(Yaf >=1.0.0)

Yaf_Response_Abstract::clearBodyDiscard all existing response bodies

Опис

public function Yaf_Response_Abstract::clearBody(string $key = ?): Yaf_Response_Abstract|false|null

Discard all existing response bodies.

Параметри

key

The content key. If specified, only that content block is cleared; otherwise, all content blocks are cleared.

Значення, що повертаються

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

Приклади

Приклад #1 Yaf_Response_Abstract::clearBody() example

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

        $response->setBody("Hello", "intro");
        $response->setBody("World");

        $response->clearBody("intro"); // drop only the "intro" block
        var_dump($response->getBody(null));

        $response->clearBody(); // drop every body block
        var_dump($response->getBody(null));
    }
}
?>

Поданий вище приклад виведе щось схоже на:

array(1) {
  ["content"]=>
  string(5) "World"
}
array(0) {
}

Прогляньте також

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top