Yaf_Dispatcher::getResponse
(Yaf >=1.0.0)
Yaf_Dispatcher::getResponse — 获取响应对象
说明
获取 dispatcher 使用的 Yaf_Response_Abstract 实例。
参数
此函数没有参数。
返回值
返回 Yaf_Response_Abstract 实例,
如果应用尚未初始化则返回 null。
示例
示例 #1 Yaf_Dispatcher::getResponse() 示例
<?php
class CharsetPlugin extends Yaf_Plugin_Abstract
{
public function preDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
{
// 与 dispatcher 持有的是同一个响应对象
Yaf_Dispatcher::getInstance()->getResponse()->setHeader(
"Content-Type", "text/html; charset=utf-8"
);
}
}
?>来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。
