Maison  >  Article  >  développement back-end  >  smarty高级特性之对象的使用方法,_PHP教程

smarty高级特性之对象的使用方法,_PHP教程

WBOY
WBOYoriginal
2016-07-12 09:02:48763parcourir

smarty高级特性之对象的使用方法,

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

<&#63;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');
&#63;>

test.tpl文件:

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

输出显示:

first dog
hello

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

您可能感兴趣的文章:

  • php实现smarty模板无限极分类的方法
  • smarty实现多级分类的方法
  • 如何在smarty中增加类似foreach的功能自动加载数据
  • 解析smarty模板中类似for的功能实现
  • php smarty 二级分类代码和模版循环例子
  • 方便实用的PHP生成静态页面类(非smarty)
  • smarty+adodb+部分自定义类的php开发模式
  • 专为新手写的结合smarty的类

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1084526.htmlTechArticlesmarty高级特性之对象的使用方法, 本文实例讲述了smarty高级特性之对象的使用方法。分享给大家供大家参考,具体如下: phpinclude_once('sm...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn