(Yaf >=1.0.0)
Yaf_Response_Abstract::clearBody — 丢弃所有已存在的响应 body
丢弃所有已存在的响应 body。
key内容 key。若指定,则只清除该内容块;否则清除所有内容块。
成功时返回响应对象自身,失败时返回 null。
示例 #1 Yaf_Response_Abstract::clearBody() 示例
<?php
class IndexController extends Yaf_Controller_Abstract
{
public function indexAction()
{
$response = $this->getResponse();
$response->setBody("Hello", "intro");
$response->setBody("World");
$response->clearBody("intro"); // 仅丢弃 "intro" 块
var_dump($response->getBody(null));
$response->clearBody(); // 丢弃所有 body 块
var_dump($response->getBody(null));
}
}
?>以上示例的输出类似于:
array(1) {
["content"]=>
string(5) "World"
}
array(0) {
}