assign("dog",$dog1);$smarty->disp..." />
 手机
当前位置:查字典教程网 >编程开发 >php教程 >smarty高级特性之对象的使用方法
smarty高级特性之对象的使用方法
摘要:本文实例讲述了smarty高级特性之对象的使用方法。分享给大家供大家参考,具体如下:name="firstdog";$smarty->ass...

本文实例讲述了smarty高级特性之对象的使用方法。分享给大家供大家参考,具体如下:

<?php include_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文件:

属性调用:{$dog->name}<br /> 方法调用:{$dog->sayHello()}

输出显示:

first dog

hello

希望本文所述对大家基于smarty的PHP程序设计有所帮助。

【smarty高级特性之对象的使用方法】相关文章:

PHP正则验证Email的方法

php中smarty区域循环的方法

php实现在服务器端调整图片大小的方法

php查询whois信息的方法

php中smarty实现多模版网站的方法

学习使用PHP数组

教你IIS6的PHP最佳配置方法

php从文件夹随机读取文件的方法

php动态函数调用方法

php对数组内元素进行随机调换的方法

精品推荐
分类导航