PHP Classes

File: example_variables.php

Recommend this page to a friend!
  Classes of Kalle Sommer Nielsen   Template Processor   example_variables.php   Download  
File: example_variables.php
Role: Example script
Content type: text/plain
Description: Example file - Using variables
Class: Template Processor
Template processing engine
Author: By
Last change: Updated to match the latest class version
Date: 17 years ago
Size: 1,103 bytes
 

Contents

Class file image Download
<?php
   
/**
     * Load class
     */
   
require_once('./template.class.php');

   
/**
     * Construct
     */
   
$temp = new Template();

   
/**
     * v1.0.2 introduced a new interface of variable types that can be
     * replaced via the replace_var(s)() and/or assign_var(s)() functions
     *
     * The phpvars and tempvars options does not exists as of v1.0.2 and
     * was replaced with 'vartype' which not only accepts 'php' and ''
     * (leave empty to use tempvars), but also 'html' and 'xhtml' look
     * a like variables.
     *
     * php:
     * $variable
     *
     * html:
     * <variable>
     *
     * xhtml:
     * <variable />
     *
     * temp:
     * {variable}
     *
     * Is the new variable replacements
     */

    /**
     * Lets say we wanna use 'xhtml' as our vartype for a small
     * 'Hello World' script
     */

    /**
     * Set configuration
     */
   
$temp->set_configuration(Array('vartype' => 'xhtml'));

   
/**
     * Add a cache template
     */
   
$temp->addcache('<helloworld />');

   
/**
     * Replace
     */
   
$temp->replace_var('helloworld', 'Hello World');

   
/**
     * Compile
     */
   
$temp->compile();
?>