PHP code example of torohill / php-template

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

    

torohill / php-template example snippets



 new \PhpTemplate\Template('hello.txt.php');
$t->greeting = 'Hello';
$t->who = 'world';

echo $t->execute();

// Alternatives:
// echo $t->execute(array('greeting' => 'Hello', 'who' => 'world'));
// echo $t->set(array('greeting' => 'Hello', 'who' => 'world'))->execute();
// echo \PhpTemplate\Template::render('hello.txt.php', array('greeting' => 'Hello', 'who' => 'world'));

<?= $greeting 


\PhpTemplate\Template;
use \PhpTemplate\Escape\HtmlEntitiesEscape;

Template::addEscape(new HtmlEntitiesEscape);

$t = new \PhpTemplate\Template('hello.html.php');
$t->greeting = '<b>Hello<b>';
$t->who = 'world';

echo $t->execute();

<?= $this->escape($greeting) 

<?= static::render('foo.php', array('foo'=>'bar')) 

<?= $this->subRender('foo.php') 

<?= static::objRender('Template', array('foo.php'), array('foo'=>'bar')) 

<?= 

"torohill/php-template": "2.*"