PHP Classes

File: docs/The div class.md

Recommend this page to a friend!
  Packages of Rafa Rodriguez   Div PHP Template Engine   docs/The div class.md   Download  
File: docs/The div class.md
Role: Example script
Content type: text/markdown
Description: Example script
Class: Div PHP Template Engine
Template processing engine that replaces tags
Author: By
Last change:
Date: 3 months ago
Size: 1,092 bytes
 

Contents

Class file image Download

All implementation of Div is the div class and different forms exist of using it. If you have another class named "div", you can rename the div class.

First, include the div.php file:

<?php

include "div.php";

// or using composer

include "path/to/vendor/autoload.php";

// div class is inside the "divengine" namespace

use divengine\div;

Variant 1: All in one instruction

echo new div('Hello {$name}', [
	'name' => 'Peter'
]);

Variant 2: First instance, then show


$t = new div('Hello {$name}', ['name' => 'Peter']);
	
echo $t; /or $t->show();/

Variant 3: The template in external file


/The file index.tpl contain the template code/
 
echo new div('index.tpl', ['name' => 'Peter']);

Variant 4: The data as JSON code


echo new div('Hello {$name}', '{name: "Peter"}');

Variant 5: The data in JSON file

/The file index.json contain the data as JSON code/

echo new div('index.tpl', 'index.json');

[[Ignore specific variables (the third parameter of constructor)]]