本文實(shí)例講述了smarty高級特性之對象的使用方法。分享給大家供大家參考,具體如下:
<?phpinclude_once('smarty.inc.php');class Dog{ public $name; public function sayHello(){ echo 'hello'; }}$dog1=new Dog();$dog1->name="first dog";$smarty->assign("dog",$dog1);$smarty->display('test.tpl');?>
test.tpl文件:
屬性調(diào)用:{$dog->name}<br />方法調(diào)用:{$dog->sayHello()}
輸出顯示:
first dog
hello
希望本文所述對大家基于smarty的PHP程序設(shè)計有所幫助。