php smarty安装,【php】smarty安装
2、解壓縮Smarty包并找到合適的位置存放,文件夾名存為是Smarty。將含有Smarty文件的文件夾拷貝到某一個(gè)目錄下。
下面內(nèi)容中,我們都是假設(shè)你的文件放在了C:\Apache2\include\Smarty下。
3、找到你的php.ini配置文件修改php.ini的include_path選項(xiàng),把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、在你的網(wǎng)站目錄下創(chuàng)建一個(gè)文件夾,名字任意,假設(shè)叫Smarty:
然后再在這個(gè)MySmarty目錄下創(chuàng)建4個(gè)文件夾,templates、configs、template-c和cache。
創(chuàng)建完成之后如下:
(你的網(wǎng)站目錄)/Smarty/templates (這個(gè)目錄用來存放模版)
(你的網(wǎng)站目錄)/Smarty/configs (這個(gè)目錄用來存放一些配置信息)
(你的網(wǎng)站目錄)/Smarty/templates-c
(這個(gè)目錄用來存放編譯文件)
(你的網(wǎng)站目錄)/Smarty/cache
(這個(gè)目錄用來存放緩存)
5、這時(shí)候你別忘了把我們上面從一開始到現(xiàn)在創(chuàng)建的四個(gè)文件夾的權(quán)限設(shè)置好。
,在“屬性”中打開“安全”標(biāo)簽,在里面列出了可以訪問這個(gè)目錄的用戶列表,
如果沒有web訪問權(quán)限,則需要添加,把Internet來賓帳戶和啟動(dòng)IIS進(jìn)程帳戶兩個(gè)帳戶都添加上即可。如果覺得麻煩,可以直接將Everyone用
戶組添加上,允許任何用戶訪問。
6、這時(shí)候安裝工作基本完成,可以進(jìn)行第一個(gè)簡單例子的測試:
在你的網(wǎng)站目錄下建立
index.php文件,并且在(網(wǎng)站目錄)/smarty/templates/下建立index.tpl文件,分別輸入以下代碼
index.php
//載入Smarty庫,如果在php.ini設(shè)置了include_path為C:\Apache2\include\Smarty\libs,那么可以直接用include("Smarty.class.php");
//另外不設(shè)置include_path,可以直接把Smarty.class.php拷到網(wǎng)站目錄,就不用加絕對(duì)路徑了。
require('Smarty.class.php');
$smarty = new Smarty;
//下面的(你的網(wǎng)站目錄)用絕對(duì)路徑,可以用相對(duì)路徑(./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前的必要參數(shù)配置
$smarty->assign('name','明天');
$smarty->display('index.tpl');
?>
index.tpl
你好,{$name}!
7、現(xiàn)在終于可以瀏覽自己的作品。運(yùn)行index.php
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的php smarty安装,【php】smarty安装的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php copy 图片_PHP-imag
- 下一篇: php从大到小排列数字,php输入几个数