PHP 8.5.10 Released!

Yaf_Dispatcher::getResponse

(Yaf >=1.0.0)

Yaf_Dispatcher::getResponse获取响应对象

说明

public function Yaf_Dispatcher::getResponse(): ?Yaf_Response_Abstract

获取 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"
        );
    }
}
?>
添加备注

用户贡献的备注

此页面尚无用户贡献的备注。
To Top