2012年5月1日 星期二

安裝smarty及基本設定

安裝smarty
www.smarty.net下載後,將libs改為smarty並放到C:\Appserv\www\myweb\class下,並修改C:/windows/php.ini將include_path="."改為include_path=".;C:\Appserv\www\myweb\class"



在php程式中加入
include('Smarty/Smarty.class.php');//載入Smarty物件類別
$smarty = new Smarty();//建立smarty物件
$smarty -> template_dir = "C:/AppServ/www/myweb/templates/";//樣版路徑
$smarty -> template_dir = "C:/AppServ/www/myweb/templates_c/";//編譯後樣版路徑
$num1 = 1500;
$num2 = 2500;
$num3 = $num1+$num2;
$smarty -> assign('num3',$num3);//將$num3的值傳給smarty的num3
$smarty -> display('index.html');//呼叫index.html

沒有留言:

張貼留言