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线性表的入栈与出栈实例分析

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

两种php调用Java对象的方法

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

PHP中4种常用的抓取网络数据方法

php转换颜色为其反色的方法

php生成图片缩略图的方法

PHP的面向对象编程

php中smarty区域循环的方法

PHP生成唯一订单号的方法汇总

精品推荐
分类导航