/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. */
  7. require('../libs/Smarty.class.php');
  8. class Person
  9. {
  10. private $m_szName;
  11. private $m_iAge;
  12. public function setName($szName)
  13. {
  14. $this->m_szName = $szName;
  15. return $this; // We now return $this (the Person)
  16. }
  17. public function setAge($iAge)
  18. {
  19. $this->m_iAge = $iAge;
  20. return $this; // Again, return our Person
  21. }
  22. public function introduce()
  23. {
  24. return 'Hello my name is '.$this->m_szName.' and I am '.$this->m_iAge.' years old.';
  25. }
  26. }
  27. $smarty = new Smarty();
  28. $smarty->allow_php_templates= true;
  29. $smarty->force_compile = false;
  30. $smarty->caching = true;
  31. $smarty->cache_lifetime = 100;
  32. //$smarty->debugging = true;
  33. $smarty->assign('foo',"'bar'");
  34. $person = new Person;
  35. $smarty->assign('person',$person);
  36. $smarty->assign('array',array('a'=>array('aa'=>'This is a long string'),'b'=>2));
  37. $smarty->display('php:index_view.php');
  38. ?>