php8.5
Home/ Manual/ yaf / yaf_dispatcher/ Yaf_Dispatcher::initView

Yaf_Dispatcher::initView

PHP function Edit on GitHub ✎

(Yaf >=1.0.0)

Initialize view and return it

Description

Yaf_Dispatcher::initView(string $templates_dir, array|null $options = null): Yaf_View_Interface|null|false

Initialize and return a Yaf_View_Simple instance bound to the dispatcher, using the given template directory.

Parameters

templates_dir

The directory that holds the view templates.

options

Options passed to the view engine, see Yaf_View_Simple::__construct.

Return Values

A Yaf_View_Interface instance on success, or false / null on failure.

Examples

Yaf_Dispatcher::initView example

php
<?php
$app = new Yaf_Application(dirname(__FILE__) . "/conf/application.ini");

$view = Yaf_Dispatcher::getInstance()->initView(
    dirname(__FILE__) . "/application/views",
    array("tpl_suffix" => ".html")
);

$view->assign("title", "Home");
?>

See Also

  • Yaf_Dispatcher::setView
  • Yaf_View_Simple

Source: reference/yaf/yaf_dispatcher/initview.xml · from the official PHP manual (php/doc-en)