Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Yaf_Dispatcher::getRequestYaf_Dispatcher::getRouter>
^Yaf_DispatcherLast updated: Mon, 26 Oct 2026

Yaf_Dispatcher::getResponse

(Yaf >=1.0.0)

Yaf_Dispatcher::getResponse — Get the response object

Description

public function Yaf_Dispatcher::getResponse(): ?Yaf_Response_Abstract

Retrieve the Yaf_Response_Abstract instance used by the dispatcher.

Parameters

This function has no parameters.

Return Values

The Yaf_Response_Abstract instance, or null if the application is not initialized.

Examples

Example #1 Yaf_Dispatcher::getResponse() example

<?php
class CharsetPlugin extends Yaf_Plugin_Abstract
{
    public function preDispatch(Yaf_Request_Abstract $request, Yaf_Response_Abstract $response)
    {
        // Same response object as the one held by the dispatcher
        Yaf_Dispatcher::getInstance()->getResponse()->setHeader(
            "Content-Type", "text/html; charset=utf-8"
        );
    }
}
?>

See Also


<Yaf_Dispatcher::getRequestYaf_Dispatcher::getRouter>
^Yaf_DispatcherLast updated: Mon, 26 Oct 2026