smarty在windows下的安装
简述
1. 从http://smarty.php.net/上下载压缩包Smarty-2.6.14.tar.tar,解压并重新命名,我将其命名为
smarty。
2. 将解压后的文件夹放在自己感觉方便的目录下,我放在了php的安装目录e:\APMServ\PHP\下。
3. 修改php的配置文件php.ini,找到;include_path = ".;c:\php\includes",在其下面一行添加语
句include_path = ".;e:\APMServ\PHP\smarty\libs",重启web服务器。
4. 在自己感觉方便的目录下建立smarty运行时需要的四个文件夹,我把他们都建立在了web目录下的工程文
档下,我的一个web工程名为files_upload,位置是www/files_upload.
建立文件夹files_upload\smarty\temlpates
files_upload\smarty\temlpates_c
files_upload\smarty\cache
files_upload\smarty\configs
安装完成。
5. 建立模板文件index.tpl放在files_upload\smarty\temlpates下
index.tpl的内容为:
<html>
<body>
Hello, {$name}!
</body>
</html>
<html>
<body>
Hello, {$name}!
</body>
</html>
建立index.php文件内容为:
<?php
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = 'e:/APMServ/www/htdocs/files_upload/smarty/temlpates';
$smarty->config_dir = 'e:/APMServ/www/htdocs/files_upload/smarty/configs';
$smarty->cache_dir = 'e:/APMServ/www/htdocs/files_upload/smarty/cache';
$smarty->compile_dir = 'e:/APMServ/www/htdocs/files_upload/smarty/templates_c';
$smarty->config_dir = 'e:/APMServ/www/htdocs/files_upload/smarty/configs';
$smarty->cache_dir = 'e:/APMServ/www/htdocs/files_upload/smarty/cache';
$smarty->compile_dir = 'e:/APMServ/www/htdocs/files_upload/smarty/templates_c';
$smarty->assign('name','fish boy!');
$smarty->display('index.tpl');
?>
$smarty->display('index.tpl');
?>
通过浏览器访问index.php,执行结果为:Hello, fish boy!!
总结:1. 关于require('Smarty.class.php');
要让系统找到Smaty.class.php文件,它被放置在smarty\libs下,所以在配置文件php.ini中
添加了语句include_path = ".;e:\APMServ\PHP\smarty\libs"。
如果不想修改php.ini文件,就要在index.php中的require语句将Smarty.class.php的绝对路
径写出来。
2. 关于 建立文件夹files_upload\smarty\temlpates
files_upload\smarty\temlpates_c
files_upload\smarty\cache
files_upload\smarty\configs
经常用到的是templates 文件夹,所有的模板文件都要放在这个文件夹下。
四个文件夹的可以放在自己方便的地方,只要在index.php中的路径变量的值和实际放置的路
径相同便可以。
如果上述输出错误,请确保文件夹的权限是不否有问题,我第一次安装进也是出错了,修改权限后就可以了.
修改的权限包括smarty文件夹
凡事往简单处想,往认真处行
本文作者:小魔鬼coder
本文链接:https://www.cnblogs.com/coderblog/archive/2008/12/11/1352888.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
标签:
smarty
, smarty在windows下的安装
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一次Java后端服务间歇性响应慢的问题排查记录
· dotnet 源代码生成器分析器入门
· ASP.NET Core 模型验证消息的本地化新姿势
· 对象命名为何需要避免'-er'和'-or'后缀
· SQL Server如何跟踪自动统计信息更新?
· “你见过凌晨四点的洛杉矶吗?”--《我们为什么要睡觉》
· C# 从零开始使用Layui.Wpf库开发WPF客户端
· 编程神器Trae:当我用上后,才知道自己的创造力被低估了多少
· C#/.NET/.NET Core技术前沿周刊 | 第 31 期(2025年3.17-3.23)
· 接口重试的7种常用方案!