最新国产好看的视频,伊人天堂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; //是否開啟緩存
$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)論

沂水县| 延津县| 天津市| 临武县| 江川县| 洱源县| 柳江县| 扶绥县| 深水埗区| 龙山县| 大埔县| 哈尔滨市| 永修县| 崇礼县| 乐昌市| 深州市| 河源市| 红桥区| 威海市| 武山县| 体育| 长宁县| 昔阳县| 犍为县| 昆山市| 九龙县| 桓台县| 南涧| 大余县| 喀喇| 余江县| 乌鲁木齐县| 岑巩县| 曲沃县| 霍林郭勒市| 万宁市| 柞水县| 迭部县| 虞城县| 正阳县| 沅陵县|