最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

smarty簡(jiǎn)單模板變量輸出方法 原創(chuàng)

原創(chuàng)  更新時(shí)間:2016年07月09日 23:43:06   原創(chuàng) 投稿:shichen2014  
這篇文章主要介紹了smarty簡(jiǎn)單模板變量輸出方法,涉及Smarty模板中數(shù)組的定義、使用及assign方法進(jìn)行變量替換的相關(guān)技巧,需要的朋友可以參考下

本文簡(jiǎn)單講述了Smarty的模板變量輸出方法。分享給大家供大家參考,具體如下:

config.inc.php配置文件如下:

include_once('smarty/Smarty.class.php');
$smarty=new Smarty();
$smarty->config_dir="smarty/Config_File.class.php";
$smarty->caching=false; //是否開(kāi)啟緩存
$smarty->template_dir="./templates"; //模板目錄
$smarty->compile_dir="./templates_c"; //編譯目錄
$smarty->cache_dir="./smarty_cache"; //緩存目錄
$smarty->left_delimiter="<{";
$smarty->right_delimiter="}>";

index.php文件如下:

include('./config.inc.php');
$title="php測(cè)試標(biāo)題";
$content="smarty練習(xí)!";
$newstext[]=array("name"=>"php程序測(cè)試","date"=>"2015-08-01");
$newstext[]=array("name"=>"php視頻教程","date"=>"2015-08-02");
$newstext[]=array("name"=>"smarty學(xué)習(xí)","date"=>"2015-08-03");
$row=array("標(biāo)題","姓名","年齡");
$smarty->assign("title",$title);
$smarty->assign("row",$row);//一個(gè)數(shù)組傳遞多個(gè)值
$smarty->assign("shownewstext",$newstext);//二維數(shù)組傳遞多個(gè)值
$smarty->assign("content",$content);
$smarty->display('index.htm');

運(yùn)行結(jié)果如下:

測(cè)試數(shù)組:標(biāo)題 | 姓名 | 年齡 
--------------------------------------------------------------------------------
測(cè)試內(nèi)容為:smarty練習(xí)! 
循環(huán)新聞內(nèi)容為:
php程序測(cè)試 - 2015-08-01
php視頻教程 - 2015-08-02
smarty學(xué)習(xí) - 2015-08-03

希望本文所述對(duì)大家基于Smarty模板的php程序設(shè)計(jì)有一定幫助作用。

相關(guān)文章

最新評(píng)論

吕梁市| 乌拉特后旗| 隆化县| 嘉定区| 名山县| 富宁县| 江达县| 松潘县| 左贡县| 福泉市| 崇仁县| 法库县| 印江| 轮台县| 清水县| 甘谷县| 安陆市| 安吉县| 台北县| 郸城县| 平定县| 云浮市| 湛江市| 盘山县| 内江市| 司法| 郸城县| 伽师县| 勃利县| 平果县| 娱乐| 建宁县| 永川市| 长顺县| 东丽区| 巫山县| 基隆市| 永和县| 扬中市| 博白县| 绥德县|