Windows下Smarty的安裝

來源:互聯網
上載者:User

下載解壓縮就不用說了
官方網站:http://smarty.php.net
php.net也有相關資料:http://news.php.net/php.smarty.dev/2703
Installation - Windows, IIS/Apache, PHP5
Extract files, rename Smarty.x.x.x to smarty (suggest OUTSIDE of your www root!)
Example: D:smarty
Run phpinfo.php to find out your php.ini location
//這個phpinfo.php在哪裡?沒找著,不Run也罷,往下看。

Edit php.ini's include_path and add the location of the libs folder.
//修改php.ini 尋找include_path這個欄位,照下面的方式修改,目錄名稱及路徑自己定義,只要與實際解壓目錄的路徑相同就OK了。
example: include_path = ".;D:smartylibs"
Restart IIS/Apache

Setup these two folders INSIDE your www root:
//在WEB伺服器根下建立templates和configs這兩個檔案(smarty目錄也是自己建的)
(wwwroot)/smarty/templates  (this is where your templates will go)
(wwwroot)/smarty/configs

Setup these two folders OUTSIDE of your www root:
//在smarty的解壓目錄建立templates_c和cache這兩個目錄。
D:/smarty/templates_c
D:/smarty/cache

Setup security settings for the webserver to write to these four folders
//templates 、configs 、templates_c 、cache 這四個目錄必須是可寫入權限

In (wwwroot) create index.php and in (wwwroot)/smarty/templates/index.tpl with the following code:
//建立index.php及index.tpl兩個檔案測試Smarty是否安裝成功,代碼如下:

index.php:

pHP代碼:

<?php

// load Smarty library
require('Smarty.class.php');

$smarty = new Smarty;

$smarty->template_dir = 'D:/inetpub/wwwroot/smarty/templates';
$smarty->config_dir = ' D:/inetpub/wwwroot/smarty/config';
$smarty->cache_dir = 'D:/smarty/smarty_cache';
$smarty->compile_dir = 'D:/smarty/smarty_templates_c';

$smarty->assign('name','fish boy!');

$smarty->display('index.tpl');
?>


index.tpl
複製內容到剪貼簿

<html>
<body>
Hello, {$name}!
</body>
</html>
Now open index.php in your web browser (requested from your webserver)
//現在運行index.php,如果看到"Hello, fish boy!! "說明安裝成功
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.