《PHP編程:smarty簡單入門實例》要點:
本文介紹了PHP編程:smarty簡單入門實例,希望對您有用。如果有疑問,可以聯系我們。
PHP編程本文以一個簡單實例分析了smarty的用法.分享給大家供大家參考.具體分析如下:
PHP編程smarty建立配置文件、顯示文件后即可,配置文件顯示文件分開來,使美工跟開發工作能完美分開
?
配置頁面代碼:index.php
代碼如下:
<?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("生活","吃飯","夢想","涼風"));?
$my->display('kk.html');? //顯示smarty目錄下的kk.html?
?>
kk.html
代碼如下:
<!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>無標題文檔</title>
</head>
<body>
{$content}?
{section name=truelife loop=$mylife}?
{$mylife[truelife]}?
{/section}?
</body>
</html>
PHP編程希望本文所述對大家的smarty程序設計有所贊助.
《PHP編程:smarty簡單入門實例》是否對您有啟發,歡迎查看更多與《PHP編程:smarty簡單入門實例》相關教程,學精學透。維易PHP學院為您提供精彩教程。
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/13557.html