PHP code example of haidarvm / simple-php-template

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

    

haidarvm / simple-php-template example snippets


//include the loader
plateEngine\Environment('path/to/templates/directory');
echo $env->render('template.php');

$env = new SimpleTemplateEngine\Environment('path/to/templates', '.php');

//will render index.php
echo $env->render('index');

//index.php
echo $env->render('template.php', ['name'=>$value, 'fruit'=>'banana']);

//template.php
My favourite fruit is  echo $fruit 

$env->helper = new Helper();
$env->colour = "green";

//inside template.php
My favourite colour is  echo $this->colour 

 $this->block('title') 

<title> echo $this['title'] 

<title>
 if(!$this['title']): 

echo $this['title']->escape();
// OR this shorthand notation
echo $this['title']->e();

 $this->block() 

 $this->block() 

 $this->extend('layout.php'); 

<!-- my layout -->
<html>
	<head>
		<title><?=$this['title'] 

$template = $env->template();
$template->extend('layout.php');
$template['content'] = "hello";
echo $template->render();