网站地图    收藏   

主页 > 后端 > smarty >

smarty的入门及简单的编码

来源:未知    时间:2014-12-11 18:17 作者:xxadmin 阅读:

[导读] smarty建立配置文件、显示文件后即可,配置文件显示文件分开来,使美工跟开发工作能完美分开 配置页面代码:index.php ?php @header( Content-type:text/html;charset=UTF-8 ); require ../libs/Smarty.class...

smarty建立配置文件、显示文件后即可,配置文件显示文件分开来,使美工跟开发工作能完美分开
 
配置页面代码:index.php

  1. <?php  
  2. @header("Content-type: text/html; charset=UTF-8");  
  3. require '../libs/Smarty.class.php';  
  4. $my=new Smarty;  
  5. $my->template_dir ='templates/';  
  6. $my->compile_dir ='templates_c/';  
  7. $my->config_dir ='configs/';  
  8. $my->cache_dir ='cache/';  
  9.  
  10. $my->assign('content','welcome to arrival');  
  11. $my->assign('mylife',array("生活","吃饭","梦想","凉风"));  
  12. $my->display('kk.html');  //显示smarty目录下的kk.html  
  13. ?> 

kk.html

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head> 
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  5. <title>无标题文档</title> 
  6. </head> 
  7. <body> 
  8. {$content}  
  9. {section name=truelife loop=$mylife}  
  10. {$mylife[truelife]}  
  11. {/section}  
  12. </body> 
  13. </html> 
  14.  

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论