smarty模板常见用法

 时间:2024-10-14 00:52:21

1、安装配置: 官网下载最新版本:http://www.smarty.net/download 解压后把libs和configs目录按如下设置拷贝出来

2、路径设置:templates/templates_c/cache/configs/libs/注意:templates_c和cache两个目录的权限要设置成777(chmod -R 777 templates_ccache)

3、Helloworld:在templates目录下增加一个demo.tpl的文件,里面写上hello worldindex.php文件如下:<?phprequ足毂忍珩ire('./libs/Smarty.class.php');$smarty = new Smarty;//$smarty->assign("result", $res);$smarty->display('demo.tpl');?>至此,基本的hello world程序就写好了,输入url,打开网页,就能看到了。smarty采用变量替换的方法,把php中的变量替换到.tpl模板文件中,tpl模板文件中的变量、表达式等语句使用{$data},这些变量在php中通过assign赋值代入

  • Smarty如何进行配置以及应用
  • 介绍Smarty在PHP中的安装和使用
  • Smarty自定义函数(plugins)
  • Smarty-php模板引擎原理
  • 模板下载吧注册教程
  • 热门搜索
    怎么做饼 女生怎么接吻 我的世界怎么盖房子 波斯菊怎么种 眼皮松弛怎么办 嗓子疼怎么办咽口水疼 被仙人掌扎了怎么办 赫拉防晒霜怎么样 电脑怎么升级 别克怎么样