Views are used to separate an application's logic from its presentation.
It's best practice to treat them only as a means of displaying the data they are given without modifying it or executing any logic.
The simple Darya\View\Php
class is provided for you to easily use PHP as a
templating engine.
An adapter already exists for the Smarty templating engine.
Adapters are planned for some popular templating engines including Blade, Twig and Mustache.
<p>Hello <?=$thing?>, this is a <?=$test?>.</p>
<?php foreach ($somethings as $something): ?>
<p><?=ucfirst($something)?> something.</p>
<?php endforeach; ?>
use Darya\View;
$view = new View\Php('views/index.php');
$view->assign(array(
'thing' => 'world',
'test' => 'test',
'somethings' => array('one', 'two', 'three')
));
echo $view->render();
<p>Hello world, this is a test.</p>
<p>One something.</p>
<p>Two something.</p>
<p>Three something.</p>