| 
									
										
										
										
											2009-08-28 18:32:31 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | /** | 
					
						
							|  |  |  | * Test script for PHP template | 
					
						
							|  |  |  | * @author Monte Ohrt <monte at ohrt dot com>  | 
					
						
							|  |  |  | * @package SmartyTestScripts | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | require('../libs/Smarty.class.php'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |  class Person | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     private $m_szName; | 
					
						
							|  |  |  |     private $m_iAge; | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     public function setName($szName) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->m_szName = $szName; | 
					
						
							|  |  |  |         return $this; // We now return $this (the Person)
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     public function setAge($iAge) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $this->m_iAge = $iAge; | 
					
						
							|  |  |  |         return $this; // Again, return our Person
 | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |      | 
					
						
							|  |  |  |     public function introduce() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |           return  'Hello my name is '.$this->m_szName.' and I am '.$this->m_iAge.' years old.'; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | }   | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $smarty = new Smarty(); | 
					
						
							| 
									
										
										
										
											2009-09-30 22:03:41 +00:00
										 |  |  | $smarty->allow_php_templates= true; | 
					
						
							| 
									
										
										
										
											2009-08-28 18:32:31 +00:00
										 |  |  | $smarty->force_compile = false; | 
					
						
							| 
									
										
										
										
											2009-09-30 22:03:41 +00:00
										 |  |  | $smarty->caching = true; | 
					
						
							|  |  |  | $smarty->cache_lifetime = 100; | 
					
						
							|  |  |  | //$smarty->debugging = true;
 | 
					
						
							| 
									
										
										
										
											2009-08-28 18:32:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-30 22:03:41 +00:00
										 |  |  | $smarty->assign('foo',"'bar'"); | 
					
						
							| 
									
										
										
										
											2009-08-28 18:32:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | $person = new Person; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $smarty->assign('person',$person); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $smarty->assign('array',array('a'=>array('aa'=>'This is a long string'),'b'=>2)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | $smarty->display('php:index_view.php'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ?>
 |