PHP Classes

File: docs/Features/Global vars.md

Recommend this page to a friend!
  Packages of Rafa Rodriguez   Div PHP Template Engine   docs/Features/Global vars.md   Download  
File: docs/Features/Global vars.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: 4 months ago
Size: 501 bytes
 

Contents

Class file image Download

The global variables conserve their value and they are independent of the instances of the div class.

Syntax in PHP

<?php
	
div::setGlobal('var-name', $mixed_value);

Example

index.php

<?php
	
div::setGlobal('today', date('Y-m-d'));
	
echo new div('index.tpl', [
	'name' => 'Peter'
]);
	
echo new div('index.tpl', [
		'name' => 'Jack'
]);

index.tpl


Hello {$name}
Today is: {$today}

Output


Hello Peter
Today is 2012-08-17
	
Hello Jack
Today is 2012-08-17