欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

smarty簡(jiǎn)單入門實(shí)例

 更新時(shí)間:2014年11月28日 10:49:21   投稿:shichen2014  
這篇文章主要介紹了smarty簡(jiǎn)單入門實(shí)例,包括了配置文件的用法與模板文件的使用,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

本文以一個(gè)簡(jiǎn)單實(shí)例分析了smarty的用法。分享給大家供大家參考。具體分析如下:

smarty建立配置文件、顯示文件后即可,配置文件顯示文件分開來,使美工跟開發(fā)工作能完美分開
 
配置頁面代碼:index.php

復(fù)制代碼 代碼如下:
<?php 
@header("Content-type: text/html; charset=UTF-8"); 
require '../libs/Smarty.class.php'; 
$my=new Smarty; 
$my->template_dir ='templates/'; 
$my->compile_dir ='templates_c/'; 
$my->config_dir ='configs/'; 
$my->cache_dir ='cache/'; 
 
$my->assign('content','welcome to arrival'); 
$my->assign('mylife',array("生活","吃飯","夢(mèng)想","涼風(fēng)")); 
$my->display('kk.html');  //顯示smarty目錄下的kk.html 
?>

kk.html
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標(biāo)題文檔</title>
</head>
<body>
{$content} 
{section name=truelife loop=$mylife} 
{$mylife[truelife]} 
{/section} 
</body>
</html>

希望本文所述對(duì)大家的smarty程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論