How to use the objects of smarty's advanced features,
The examples in this article describe how to use the objects of smarty's advanced features. Share it with everyone for your reference, the details are as follows:
<?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');
?>
Copy after login
test.tpl file:
属性调用:{$dog->name}<br />
方法调用:{$dog->sayHello()}
Copy after login
Output display:
first dog
hello
I hope this article will be helpful to everyone’s PHP program design based on smarty.
Articles you may be interested in:
- How to implement infinite classification of smarty templates in php
- How to implement multi-level classification in smarty
- How to implement infinite classification in smarty Add foreach-like functions to automatically load data
- Analyze for-like functions in smarty templates
- php smarty secondary classification code and template loop examples
- Convenient and practical PHP Generate static page classes (non-smarty)
- smarty adodb PHP development mode for some custom classes
- Categories written specifically for novices combined with smarty
http://www.bkjia.com/PHPjc/1084526.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1084526.htmlTechArticleHow to use objects with advanced features of smarty. This article describes how to use objects with advanced features of smarty. Share it with everyone for your reference, the details are as follows: phpinclude_once('sm...