PHP Classes

File: examples/functions.php

Recommend this page to a friend!
  Classes of tokkara   Simphple   examples/functions.php   Download  
File: examples/functions.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simphple
Process templates compiling into PHP code
Author: By
Last change: simphple version 1.1.0
Date: 11 years ago
Size: 1,084 bytes
 

Contents

Class file image Download
<?php

include '../simphple/data_store/data_store.intfc.php';
include
'../simphple/data_store/data_store_file.class.php';

include
'../simphple/template/template_code.class.php';
include
'../simphple/template/template.class.php';
include
'../simphple/template/template_function.class.php';
include
'../simphple/template/template_tools.class.php';

$dsf = new Sphp_Data_Store_File('cache/', true, true);
$options = array('debug' => true, 'template_dir_path' => 'templates/');
$tpl = new Sphp_Template($dsf, $options);

class
Test{
    public static function
uppercase($str){
        return
strtoupper($str);
    }
   
    public function
lowercase($str){
         return
strtolower($str);
    }
}

$func1 = new Sphp_Template_Function('first_uppercase', 'ucfirst');
$func2 = new Sphp_Template_Function('static_method', 'Test::uppercase');
$func3 = new Sphp_Template_Function('method', 'lowercase', new Test());

$tpl->add_function($func1);
$tpl->add_function($func2);
$tpl->add_function($func3);
$tpl->add_variable('var1', 'All LOWERcase');

$tpl->display_file('functions.html');