php與php MySQL 之間的關系
826
2023-12-09
本文實例講述了Smarty模板簡單配置與使用方法。分享給大家供大家參考,具體如下:
在Smarty目錄中建立templates,templates_c,configs,cache目錄。以便Smarty進行編譯和緩存。
建立smarty_inc.php文件對smarty進行配置如下:
<?php include_once("./smarty/Smarty.class.php"); //包含smarty類文件 $smarty = new Smarty(); //建立smarty實例對象$smarty $smarty->caching=false; //開發是不建議開啟緩存 $smarty->template_dir="./templates"; //設置模板目錄 $smarty->compile_dir="./templates_c"; //設置編譯目錄 $smarty->cache_dir="./cache"; //緩存文件夾 $smarty->cache_lifetime=60; $smarty->left_delimiter = "<{"; //左定界符 $smarty->right_delimiter = "}>"; //右定界符 ?>
行測試,在根目錄下建立index.php文件:
<?php include("smarty_inc.php"); $val= array("丁慶","董丹鳳","情侶"); $smarty->assign("name",$val); $smarty->display("index.html"); ?>
在templates下建立index.html模板:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset="utf-8"> <title>測試頁面</title> </head> <body> <{foreach from=$name item=x}> 數組內容:<{$x}> <br/> <{/foreach}> </body> </html>
好了,大功告成,就是這么簡單。
更多關于Smarty相關內容可查看本站專題:《smarty模板入門基礎教程》、《PHP模板技術總結》、《PHP基于pdo操作數據庫技巧總結》、《PHP運算與運算符用法總結》、《PHP網絡編程技巧總結》、《PHP基本語法入門教程》、《php面向對象程序設計入門教程》、《php字符串(string)用法總結》、《php+mysql數據庫操作入門教程》及《php常見數據庫操作技巧匯總》
希望本文所述對大家基于smarty模板的PHP程序設計有所幫助。
#免責聲明#
本站[綠夏技術導航]提供的一切軟件、教程和內容信息僅限用于學習和研究目的;不得將上述內容用于商業或者非法用途,否則,一切后果請用戶自負。本站信息來自網絡收集整理,版權爭議與本站無關。您必須在下載后的24個小時之內,從您的電腦或手機中徹底刪除上述內容。如果您喜歡該程序或內容,請支持正版,購買注冊,得到更好的正版服務。我們非常重視版權問題,如有侵權請郵件[admin@lxwl520.com]與我們聯系進行刪除處理。敬請諒解!