Yaf_Response_Abstract::clearBody
Discard all existing response bodies
Description
public Yaf_Response_Abstractfalsenull Yaf_Response_Abstract::clearBody(string $key = ?)
Discard all existing response bodies.
Parameters
-
key
-
The 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
Example #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));
}
}
?>
The above example will output
something similar to:
array(1) {
["content"]=>
string(5) "World"
}
array(0) {
}
See Also
- Yaf_Response_Abstract::setBody
- Yaf_Response_Abstract::appendBody
- Yaf_Response_Abstract::prependBody
- Yaf_Response_Abstract::getBody