?
This document uses PHP Chinese website manual Release
This is a continuation of the basic
installation, please read that first!
這是基本安裝的繼續(xù),請(qǐng)先閱讀那個(gè)文件!
A slightly more flexible way to setup Smarty is to extend the class and initialize your Smarty environment. So instead of repeatedly setting directory paths, assigning the same vars, etc., we can do that in one place. Lets create a new directory "/php/includes/guestbook/" and make a new file called "setup.php". In our example environment, "/php/includes" is in our include_path. Be sure you set this up too, or use absolute file paths.
一個(gè)更靈活一點(diǎn)的配置Smarty的方法是擴(kuò)展類(lèi),和初始化你的smarty環(huán)境。
為了避免重復(fù)地配置路徑,我們可以在一個(gè)文件里配置這些變量。
我們創(chuàng)建一個(gè)目錄 "/php/includes/guestbook/" 建立一個(gè)文件"setup.php"
同樣先設(shè)置好smarty路徑。
Example 2-10. Editing /php/includes/guestbook/setup.php
|
Now lets alter the index.php file to use setup.php:
現(xiàn)在我們針對(duì)setup文件更改一下index文件
Example 2-11. Editing /web/www.mydomain.com/docs/guestbook/index.php
|
Now you see it is quite simple to bring up an instance of Smarty, just use
Smarty_GuestBook which automatically initializes everything for our application.
現(xiàn)在你看到創(chuàng)建一個(gè)使用smarty的實(shí)例有多么的簡(jiǎn)單.從Smarty_GuestBook開(kāi)始,重新構(gòu)建我們的應(yīng)用程序吧^_^