PHP Classes

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Archzilon Eshun-Davies  >  cTemplate  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script of how to use cTemplate.php
Class: cTemplate
Template engine based on string replacement
Author: By
Last change: Fixed a typo with the template from string. Thanks to Darren Conyard for noticing this
Date: 2 years ago
Size: 651 bytes


Class file image Download
     * This is the example script of how to use cTemplate.php
     * this has two exapmles, one is to show how to make a templte
     * from string and the second is to show how to use a template file

$tpl = new cTemplate();
# String Template
$templatestring = "Hello {NAME}, You have {NUMBERMAILS} new messages";
# Template in a file
$templatefile = "dashboard.tpl";

$tpl->setvar("NAME", "laudarch");
$tpl->setvar("NUMBERMAILS", "10");

# show template from string
print $tpl->gettpl($templatestring);

# show template from file
print $tpl->gettpl_file($templatefile);