Yaf_Response_Abstract::clearBody
PHP function
Edit on GitHub ✎
(Yaf >=1.0.0)
Discard all existing response bodies
Description
Yaf_Response_Abstract::clearBody([string $key]): Yaf_Response_Abstract|false|null
Discard all existing response bodies.
Parameters
keyThe content key. If specified, only that content block is cleared; otherwise, all content blocks are cleared.
Return Values
Returns the response object itself on success, or null on failure.
Examples
Yaf_Response_Abstract::clearBody example
php
<?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));
}
}
?>The above example will output something similar to:
output
array(1) {
["content"]=>
string(5) "World"
}
array(0) {
}See Also
Yaf_Response_Abstract::setBodyYaf_Response_Abstract::appendBodyYaf_Response_Abstract::prependBodyYaf_Response_Abstract::getBody