PHP code example of phower / view

1. Go to this page and download the library: Download phower/view library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phower / view example snippets


<h1>Hello <?= $name 

use Phower\View\TemplateView;

$view = new TemplateView();
$view->setTemplate('my_template.php');
$view->setVariables(['name'] => 'Pedro');

$view->render(); // outputs: <h1>Hello Pedro!</h1>

use Phower\View\TemplateView;

$child = new TemplateView();
$child->setTemplate('child_template.php');

$parent = new TemplateView();
$parent->setTemplate('parent_template.php');
$parent->capture('child', $child);

$parent->render();

use Phower\View\JsonView;

$view = new JsonView();
$view->setVariables(['name'] => 'Pedro');

$view->render(); // outputs: {"name":"Pedro"}