Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  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: 2013-01-08 14:24
Size: 651 bytes
 

Contents

Class file image Download
<?php
    
/*
     * 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
     */
    
require_once("cTemplate.php");

    
$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);
?>