windows 安裝 smarty 步驟

來源:互聯網
上載者:User

1、下載Smarty包
可以從官方網站下載:http://smarty.php.net

 

2、解壓縮Smarty包並找到合適的位置存放,檔案夾名存為是Smarty。將含有Smarty檔案的檔案夾拷貝到某一個目錄下。

下面內容中,我們都是假設你的檔案放在了C:/Apache2/include/Smarty下。

 

3、找到你的php.ini設定檔修改php.ini的include_path選項,把smarty的庫檔案路徑加上,比如:
include_path = "C:/Apache2/include/Smarty/libs"

提醒一下,php.ini中一共有兩處include_path,一處是Unix下使用的,一處是windows下使用的,要修改windows下使用的:
-------------------------------------------------------------
; Windows: "/path1;/path2"
include_path = "C:/Apache2/include/Smarty/libs"

 

4、在你的網站目錄下建立一個檔案夾,名字任意,假設叫Smarty:
然後再在這個MySmarty目錄下建立4個檔案夾,templates、configs、template-c和cache。
建立完成之後如下:
(你的網站目錄)/Smarty/templates (這個目錄用來存放模版)
(你的網站目錄)/Smarty/configs (這個目錄用來存放一些配置資訊)

(你的網站目錄)/Smarty/templates-c (這個目錄用來存放編譯檔案)

(你的網站目錄)/Smarty/cache (這個目錄用來存放緩衝)

 

5、這時候你別忘了把我們上面從一開始到現在建立的四個檔案夾的使用權限設定好。

,在“屬性”中開啟“安全”標籤,在裡面列出了可以訪問這個目錄的使用者列表,

如果沒有web存取權限,則需要添加,把Internet來賓帳戶和啟動IIS進程帳戶兩個帳戶都添加上即可。如果覺得麻煩,可以直接將Everyone用

戶組添加上,允許任何使用者訪問。

6、這時候安裝工作基本完成,可以進行第一個簡單例子的測試:
在你的網站目錄下建立 index.php檔案,並且在(網站目錄)/smarty/templates/下建立index.tpl檔案,分別輸入以下代碼
index.php
<?php
//載入Smarty庫,如果在php.ini設定了include_path為C:/Apache2/include/Smarty/libs,那麼可以直接用include("Smarty.class.php");
//另外不設定include_path,可以直接把Smarty.class.php拷到網站目錄,就不用加絕對路徑了。
require('Smarty.class.php');

$smarty = new Smarty;

//下面的(你的網站目錄)用絕對路徑,可以用相對路徑(./templates)
$smarty->template_dir='E:/site/smarty/templates';
$smarty->config_dir='E:/site/smarty/configs';
$smarty->cache_dir='E:/site/smartycache';
$smarty->compile_dir='E:/site/smarty/templates_c';
//上面四行為使用Smarty前的必要參數配置

$smarty->assign('name','明天');
$smarty->display('index.tpl');
?>
index.tpl
<html>
<body>
你好,{$name}!
</body>
</html>

 

7、現在終於可以瀏覽自己的作品。運行index.php

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.