[精讚] [會員登入]
1860

Smarty安裝

smarty 是著名的樣版引擎,非常的好用,用多了突然發現拿掉smarty反而不會寫php了,以下是安裝過程..

分享此文連結 //n.sfs.tw/10112

分享連結 Smarty安裝@新精讚
(文章歡迎轉載,務必尊重版權註明連結來源)
2019-10-24 08:51:01 最後編修
2016-10-31 07:47:05 By 張○○
 

自動目錄

程式需求

Smarty requires PHP 4.0.6 or later.

安裝

一、下載 http://www.smarty.net/download.php 及解壓,例如解壓到 /path/to/smarty/

二、建立目錄於解壓的smarty 目錄中 "templates", "configs", and   "templates_c", "cache"

$ chmod 777 cache/
$ chmod 777 templates_c

三、SELinux打開寫入權限

$ chcon -t httpd_sys_rw_content_t /path/to/smarty/templates_c -R
$ chcon -t httpd_sys_rw_content_t /path/to/smarty/cache -R

四、PHP程式的引用

include "path/to/smarty/Smarty.class.php";      //讀入SMARTY函式庫
初始宣告 Smarty() 類別
$view = new Smarty();

五、Smarty 的常數設定

$SITE_ROOT = "smarty/";

$view->template_dir = $SITE_ROOT . "/templates/";
$view->compile_dir = $SITE_ROOT . "/templates_c/";
$view->config_dir = $SITE_ROOT . "/configs/";
$view->cache_dir = $SITE_ROOT . "/cache/";
$view->left_delimiter = '{{';
$view->right_delimiter = '}}';

六、樣版變數的指定

以下範例指定樣板中變數 $test 的值
$view->assign("test","This is a Test String");
以下範例在網頁中顯示樣板 index.tpl
$view->display('index.tpl');

七、樣板的使用範例

index.tpl

<body>
這是一個範例 {{$test}} 
</body>

整理 2009-02-21 01:55:48

END

你可能感興趣的文章

PHP 數字加解密函式 自寫的數字加解密,勉強用

[PHP] 使用FTP PHP 上使用 FTP 的寫法

[PHP] 2個程式的觀念 整理2個PHP的程式觀念,參考參考。

[PHP] 判斷文字、數字、文字加數字的方法 幾個PHP數字和文字操作上的小眉角:判斷文字、數字、文字加數字的方法

[PHP+ci4] codeignitor4+ smarty5 這篇整合 php 的framework codeignitor4 + smarty5。

[PHP+ci4] codeignitor4 Cache 及 Session 使用 memcached php 的framework codeignitor4 中的cache和session使用memcached

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

[MAC] 截取螢幕畫面的方法 截取螢幕畫面的方法,在MAC中叫作螢幕快照,英文是screenshot

[jQuery] 利用load()來達成ajax的寫法 jQuery中利用load()來達成ajax的寫法,也有人稱他是假的ajax,作法就是..

PHP for sphinx 函式庫安裝 PECL/sphinx PHP>= 5.2.2 已經能原生支援 sphinx,可是預設的沒有裝,我們得自己裝才能用

[Win7] 燒錄 iso 檔 在Windows7 中內建燒錄程式,可以直接把檔案拉到光碟機裡,再執行燒錄。

[JAVA] JWS, JWT, JWE, JOSE是什麼? [JAVA] JWS, JWT, JWE, JOSE是什麼?非常的複雜,儘量來搞清楚..