php smarty安装,【php】smarty安装
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
//載入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
你好,{$name}!
7、現在終于可以瀏覽自己的作品。運行index.php
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的php smarty安装,【php】smarty安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php copy 图片_PHP-imag
- 下一篇: php从大到小排列数字,php输入几个数