PHP code example of pavel852 / php-templates

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

    

pavel852 / php-templates example snippets


     
     $t = tmpl_open("example.html");
     

     
     tmpl_close($t);
     

     
     tmpl_set($t, "title", "Moje stránka");
     tmpl_set($t, "header_text", "Vítejte!");
     

     
     $data = [
         "title" => "Moje stránka",
         "header_text" => "Vítejte!",
         "content" => "Toto je obsah stránky."
     ];
     tmpl_set_array($t, $data);
     

     
     tmpl_iterate($t, "menu_items");
     

     
     echo tmpl_parse($t);
     

     
     tmpl_

     
     if (tmpl_exists($t, "footer")) {
         tmpl_set($t, "footer", "Zápatí existuje!");
     }
     


tmpl_open("example.html");

tmpl_set($t, "title", "Moje Stránka");
tmpl_set($t, "header_text", "Vítejte!");
tmpl_set($t, "content", "Toto je obsah stránky.");

echo tmpl_parse($t);
tmpl_close($t);


$t = tmpl_open("menu.html");
$menu_items = [
    ["name" => "Domů", "link" => "/home"],
    ["name" => "O nás", "link" => "/about"],
    ["name" => "Kontakt", "link" => "/contact"]
];
tmpl_set_iarray($t, "menu_items", $menu_items);
echo tmpl_parse($t);
tmpl_close($t);