PHP Classes

File: docs/Features/Simple replacements.md

Recommend this page to a friend!
  Packages of Rafa Rodriguez   Div PHP Template Engine   docs/Features/Simple replacements.md   Download  
File: docs/Features/Simple replacements.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: 763 bytes
 

Contents

Class file image Download

A simple replacement is the replacement of parts of the template with any content. The variable can be contain a mixed value:

  • If the value is a string, the replacement is the string.
  • If the value is a number, the replacement is the "number".
  • If the value is an array, the replacement is the length of the array.
  • If the value is an object without __toString method implemented, the replacement is the count of properties of the object.

Syntax in templates

{$varname}

Example:

index.php

<?php
	
include 'div.php';
	
echo new div('index.tpl', [
	'first_name' => 'Peter',
	'last_name' => 'Pan'
]);

index.tpl

First name: {$first_name}
Last name: {$last_name}

Output

First name: Peter
Last name: Pan