首先index.php
<?php
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir= 'D:/APMXE5/htdocs/hust/MySmarty/templates';
$smarty->config_dir = 'D:/APMXE5/htdocs/hust/MySmarty/configs';
$smarty->cache_dir = 'D:/APMXE5/htdocs/hust/MySmarty/cache';
$smarty->compile_dir = 'D:/APMXE5/htdocs/hust/MySmarty/templates_c';
$smarty->assign('name','跟17PHP学安装Smarty');
$smarty->caching = true;
$smarty->display('index.tpl'); ?>
运行后没有问题!!
...........................................................................
下面我把基本设置写成了一个类,在调用:
setup.php
<?php
// load Smarty library
require('Smarty.class.php');// The setup.php file is a good place to load
// required application library files, and you
// can do that right here. An example:
// require('guestbook/guestbook.lib.php');是一个很好的加载应用程序的类库文件(就是扩展类)
//例如你可以在index文件里包含它class Smarty_GuestBook extends Smarty { function Smarty_GuestBook() {
// Class Constructor. These automatically get set with each new instance.
//类构造函数.创建实例的时候自动配置 $this->Smarty();
$smarty->template_dir= 'D:/APMXE5/htdocs/hust/MySmarty/templates/';
$smarty->config_dir = 'D:/APMXE5/htdocs/hust/MySmarty/configs/';
$smarty->cache_dir = 'D:/APMXE5/htdocs/hust/MySmarty/cache/';
$smarty->compile_dir = 'D:/APMXE5/htdocs/hust/MySmarty/templates_c/';
$this->caching = true;
$this->assign('name','跟17PHP学安装Smarty');
}}?>
.........................................................................
index.php<?phprequire('setup.php');$smarty = new Smarty_GuestBook;$smarty->assign('name','Ned');$smarty->display('index.tpl');?> 运行后出现一下错误:
Fatal error: Smarty error: the $cache_dir 'cache' does not exist, or is not a directory. in d:\Smarty\libs\Smarty.class.php on line 1095
高手看看这是什么问题呢???
<?php
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir= 'D:/APMXE5/htdocs/hust/MySmarty/templates';
$smarty->config_dir = 'D:/APMXE5/htdocs/hust/MySmarty/configs';
$smarty->cache_dir = 'D:/APMXE5/htdocs/hust/MySmarty/cache';
$smarty->compile_dir = 'D:/APMXE5/htdocs/hust/MySmarty/templates_c';
$smarty->assign('name','跟17PHP学安装Smarty');
$smarty->caching = true;
$smarty->display('index.tpl'); ?>
运行后没有问题!!
...........................................................................
下面我把基本设置写成了一个类,在调用:
setup.php
<?php
// load Smarty library
require('Smarty.class.php');// The setup.php file is a good place to load
// required application library files, and you
// can do that right here. An example:
// require('guestbook/guestbook.lib.php');是一个很好的加载应用程序的类库文件(就是扩展类)
//例如你可以在index文件里包含它class Smarty_GuestBook extends Smarty { function Smarty_GuestBook() {
// Class Constructor. These automatically get set with each new instance.
//类构造函数.创建实例的时候自动配置 $this->Smarty();
$smarty->template_dir= 'D:/APMXE5/htdocs/hust/MySmarty/templates/';
$smarty->config_dir = 'D:/APMXE5/htdocs/hust/MySmarty/configs/';
$smarty->cache_dir = 'D:/APMXE5/htdocs/hust/MySmarty/cache/';
$smarty->compile_dir = 'D:/APMXE5/htdocs/hust/MySmarty/templates_c/';
$this->caching = true;
$this->assign('name','跟17PHP学安装Smarty');
}}?>
.........................................................................
index.php<?phprequire('setup.php');$smarty = new Smarty_GuestBook;$smarty->assign('name','Ned');$smarty->display('index.tpl');?> 运行后出现一下错误:
Fatal error: Smarty error: the $cache_dir 'cache' does not exist, or is not a directory. in d:\Smarty\libs\Smarty.class.php on line 1095
高手看看这是什么问题呢???
解决方案 »
- 没有找到 PHP 扩展 mbstring,而您现在好像在使用多字节字符集。没有 mbstring 扩展的 phpMyAdmin 不能正确分割字符串,可能产生意想
- 用smarty用得吐血的一个事……
- 路径问题,请大家看指点一下
- 这句重定向语句怎么加入.htaccess才能生效啊?
- 测试XXTea算法,网上没有一个php版本能还原我的字符串,太奇葩了。
- 自己开发的BLOG终于可以见人了,欢迎大家测试!喜欢的朋友帮顶一下
- 在win下可以执行。在服务器上却不能执行了。。。是权限不够吗?
- 我用PHP在基于文件读写的基础上做的数据库,我把她叫做File Database。
- 如何在Linux下调试PHP?
- URL带参数的重定向
- 谁知道fpdf.org的网站为什么打不开了?
- Php 解析 XML遇到的问题
cache文件夹里多了这个文件:%%45^45E^45E480CD%%index.tpl
templates_c文件夹里多了两个文件:%%45^45E^45E480CD%%index.tpl.php 和wrt34.tmp