PHP code example of esase / tiny-view

1. Go to this page and download the library: Download esase/tiny-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/ */

    

esase / tiny-view example snippets




    use Tiny\View\View;

    // we are going to show the user list
    $view = new View(['users' => [ // an array of users
            ['id' => 1, 'name' => 'Tester1'],
            ['id' => 2, 'name' => 'Tester2']
        ]],
        './users.phtml', // a template for the data,
        './layout/base.phtml' // a layout it's optional 
    );

    // render the template using passed variables and wrap its content to a layout
    echo $view;

html
<ul>
     foreach ($this->users as $user):