《PHP实例:smarty模板引擎中变量及变量修饰器用法实例》要点:
本文介绍了PHP实例:smarty模板引擎中变量及变量修饰器用法实例,希望对您有用。如果有疑问,可以联系我们。
本文实例讲述了smarty变量及变量修饰器的应用.分享给大家供大家参考.具体如下:PHP实战
模板文件:temp.htm:
PHP实战
php文件:index.php
PHP实战
class Dog{
public $name;
public $age;
function leee(){
return $this->name."在干吗";
}
}
$dog = new Dog();
$dog->name="小狗";
$smarty->assign("dog",$dog);PHP实战
//$str = "hello world,i am here. i love smarty!";
$str = "帅锅";
$str1 = "<a href='http://www.sina.com/'>新浪</a> And\n aassu@163.com";
$str2 = "aassu@163.com";
$smarty->assign("str",$str);
$smarty->assign("str1",$str1);
$smarty->assign("str2",$str2);
$smarty->assign("number",30.293934);
$smarty->assign("str3","akie abfal <a;fa>,dooerw,show databases,desc table");PHP实战
$config = "Y-m-d H:i:s";
$smarty->assign("config",$config);
$smarty->assign("yesterday",strtotime('-1 day'));
//常量
define("MY_CONST","百度");PHP实战
//append成员办法的使用
$family = array("husband"=>"帅锅","wife"=>"美女");
$famiadd = array("boy"=>"张三丰","girl"=>"王昭君");
$smarty->append("family",$family);
$smarty->append("family",$famiadd);
echo "<pre>";
print_r($family);
$smarty->display("temp.htm");
?>PHP实战
希望本文所述对大家的php程序设计有所赞助.PHP实战
《PHP实例:smarty模板引擎中变量及变量修饰器用法实例》是否对您有启发,欢迎查看更多与《PHP实例:smarty模板引擎中变量及变量修饰器用法实例》相关教程,学精学透。维易PHP学院为您提供精彩教程。