本站最近更新 - 使用說明 - 測試沙箱 - 搜尋 Wiki:

主選單

FreeBSD

PcBSD 0.83

Windows

程式語言

(edit)



編輯本頁 列印預覽 群組最近更新 本頁更新歷程
Smarty 是 PHP 的範本之一, 想對他有更深入的了解請上 http://smarty.php.net/

安裝環境 FreeBSD 5.3 + Apache 1.3 + PHP 4.11

Step.1 安裝 Smarty
 # cd /usr/ports/www/smarty
 # make install 

Step.2 修改 php.ini
 若在 /usr/local/etc 中找不到 php.ini 請將 php.ini-dist 複製成 php.ini
 編輯此檔加上

 include_path = ".:/usr/local/share/smarty"

Step.3 建立相關目錄、變更權限
 # cd /usr/local/www/data
 # mkdir templates; mkdir templates_c;mkdir configs;mkdir cache
 # chown nobody:nobody templates_c;chown nobody:nobody cache
 # chmod 777 templates_c;chmod 777 cache

 ? 根據手冊上寫的 770 權限,沒辦法正常運作

Step.4 啟動 Apache
 # /usr/local/sbin/apache start

Step.5 測試 smarty

a. 編輯 hello.php
 <?
    require("Smarty.class.php"); 
    $tpl = new Smarty();
    $tpl->assign("title", "我的第一個 smarty 程式");
    $tpl->assign("content", "Hello world!!");
    $tpl->display('hello.htm');
 ?> 
b. 編輯 hello.htm (此檔需放在 templates 目錄中)
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=big5">
 <title>{$title}</title>
 </head>
 <body>
 {$content}
 </body>
 </html>

編輯完後,打開流灠器輸入網址與檔名 (hello.php) 就可以看到結果了。

編輯本頁 - 列印預覽 - 群組最近更新 - 本頁更新歷程 - 搜尋 Wiki
頁面最後更新於 2006 年 12 月 28 日,05:33 PM