一、SMARTY安装于配置文件
2016-05-10 09:22
169 查看
安装Smarty发行版在/libs/目录里的库文件(就是解压了). 这些php文件你可不能乱画哦.这些文件被所有应用程序共享,也只能在你升级到新版的smarty的时候得到更新。 Smarty手册范例 2-1.Smarty库文件 Smarty.class.php Smarty_Compiler.class.php Config_File.class.php debug.tpl /core/*.php (all of them) /plugins/*.php (all of them) Smarty使用一个叫做'SMARTY_DIR'的php常量作为它的系统库目录。基本上,如果你的应用程序可以找到 Smarty.class.php文件,你不需要设置SMARTY_DIR,Smarty将会自己运作。但是,如果 Smarty.class.php没有在你的include_path(php.ini里的一项设置)里,或者没有在你的应用程序里设置它的绝对路径的时候,你就必须手动配置SMARTY_DIR 了(大多数程序都如此)SMARTY_DIR必须包含结尾斜杠。 这里是你在你的php脚本里创建一个smarty的应用实例的例子: require('Smarty.class.php'); $smarty = new Smarty; 试着运行一下以上脚本,如果你发现"未找到Smarty.class.php 文件"的错误时,你应该这样做: Smarty手册范例 2-3.加入库文件目录的绝对路径 require('/usr/local/lib/php/Smarty/Smarty.class.php'); $smarty = new Smarty; Smarty手册范例 2-4.在include_path加入库文件目录 // Edit your php.ini file, add the Smarty library // directory to the include_path and restart web server. // Then the following should work: require('Smarty.class.php'); $smarty = new Smarty; Smarty手册范例 2-5.手工设置SMARTY_DIR常量 define('SMARTY_DIR','/usr/local/lib/php/Smarty/'); require(SMARTY_DIR.'Smarty.class.php'); $smarty = new Smarty; 现在库文件已经搞定,该是设置为你的应用程序配置其他有关Smarty的目录的时候了。Smarty要求4个目录,默认下命名为:tempalates, templates_c, configs and cache。每个都是可以自定义的,可以修改Smarty类属性: $template_dir, $compile_dir, $config_dir, and $cache_dir respectively。强烈推荐你为每个用到smarty的应用程序设置单一的目录! 确定你已经知道了你的web服务器文件根目录。在我们的例子里,文件根目录是:"/web/www.mydomain.com/docs/"Smarty的4个目录 只可以被那些库文件访问,不可以被网络上的浏览器访问的目录。因此为避免任何安全问题,要求将那4个目录和网页文件目录(就是浏览器看的)分开来。
相关文章推荐
- iOS开发XCODE5 SVN配置 使用办法 (转) 收藏一下
- 每天laravel-20160803| Container -6
- 听君一席话,胜读十年书
- 开源网络蜘蛛(Spider)一览
- 每天laravel-20160803| Container -6
- 连接oracle读取数据
- MyEclips中JS代码提示插件(spket)
- 在iOS App中实现地理位置定位的基本方法解析
- 2016-05-09Load事件、public Form1()和 Paint事件
- 机器学习中的归一化问题
- Hadoop资源管理
- 小米微信浏览器window.location.href不跳转
- 提高 ASP.NET Web 应用性能的 24 种方法和技巧
- android 通过shape设置圆形按钮
- php pi() 或M_PI(常量)
- 抽奖(转)
- 简单易懂的KMP,NEXT数组,BF算法(实例讲解)!!!
- 对于格式化字符串的总结
- 错误:The Operation Couldn't be Completed
- Android TextView结合SpannableString使用大全