PHP 8.5.10 Released!

Yaf_View_Simple::__construct

(Yaf >=1.0.0)

Yaf_View_Simple::__constructConstructor of Yaf_View_Simple

Description

publicfunction Yaf_View_Simple::__construct(string $template_dir, array $options = NULL)

Yaf_View_Simple is the default and only view engine Yaf supports out of the box. An instance is created automatically by the Yaf_Dispatcher when the application starts; instantiating it directly is only needed to render templates outside of the dispatch flow.

The template_dir argument must point to an existing directory containing the view scripts; it becomes the script path of the view and can later be changed with Yaf_View_Simple::setScriptPath().

Parameters

template_dir

The directory where the template scripts are stored.

options

Optional view options as an array. Reserved for custom view engine implementations; the built-in engine accepts but does not use it.

Return Values

No value is returned.

Examples

Example #1 Yaf_View_Simple::__construct() example

<?php
define("TEMPLATE_DIRECTORY", APPLICATION_PATH . '/views');
$view = new Yaf_View_Simple(TEMPLATE_DIRECTORY);
$view->assign("name", "world");
echo $view->render("greeting.phtml");
?>

See Also

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top