PageRenderTime 14ms CodeModel.GetById 11ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/vendor/smarty3/lib/demo/index_php_template.php

http://zoop.googlecode.com/
PHP | 49 lines | 32 code | 11 blank | 6 comment | 0 complexity | 7716ff5f63faecbcfb6ca06b717aa2d0 MD5 | raw file
 1<?php
 2/**
 3* Test script for PHP template
 4* @author Monte Ohrt <monte at ohrt dot com> 
 5* @package SmartyTestScripts
 6*/
 7require('../libs/Smarty.class.php');
 8
 9 class Person
10{
11    private $m_szName;
12    private $m_iAge;
13    
14    public function setName($szName)
15    {
16        $this->m_szName = $szName;
17        return $this; // We now return $this (the Person)
18    }
19    
20    public function setAge($iAge)
21    {
22        $this->m_iAge = $iAge;
23        return $this; // Again, return our Person
24    }
25    
26    public function introduce()
27    {
28          return  'Hello my name is '.$this->m_szName.' and I am '.$this->m_iAge.' years old.';
29    }
30}  
31
32$smarty = new Smarty();
33$smarty->allow_php_templates= true;
34$smarty->force_compile = false;
35$smarty->caching = true;
36$smarty->cache_lifetime = 100;
37//$smarty->debugging = true;
38
39$smarty->assign('foo',"'bar'");
40
41$person = new Person;
42
43$smarty->assign('person',$person);
44
45$smarty->assign('array',array('a'=>array('aa'=>'This is a long string'),'b'=>2));
46
47$smarty->display('php:index_view.php');
48
49?>