apache有权限写'/var/www/html/Smarty/templates_c/‘ 这个目录吗?你的test.htm放在那个目录里啊?
解决方案 »
- php列表页向文章页跳转问题
- 急!!有一连串的问题带你解决!在线等!
- jquery中如何设置一个radio(input)为选中状态
- 数据库连接问题
- 关于每日定时自动更新数据表的解决方案
- 一个弱问题,今天在教程上看到这样一句话:"若php以模块方式执行.......",请问什么是以模块方式执行,还可以以什么方式执行?
- 寻兼职(可短期内Full Time)PHP高手1-2名
- 如何判断用户名已经存在并返回错误信息...50分
- IIS+PHP 只能访问首页,其它页面全是404错误,求有经验的人帮忙!!
- PHP处理图像合成后白色部分变成黑色怎么解决??
- 如何让服务器支持中文名文件,本论坛搜不到的问题~
- 如何在本地网页中隐形实现另一个网站的身份验证来登录那个网站
templates_c和cache必需可写
index.php
<?
include_once('smarty/Smarty.class.php');
$broadcast = '你好!!';
//创建模板
$smarty = new Smarty;
$smarty->template_dir = './';
$smarty->compile_dir = './templates_c/';
$smarty->config_dir = './configs/';
$smarty->cache_dir = './cache/';
$smarty->left_delimiter = '{<';
$smarty->right_delimiter = '>}'; $smarty->assign('broadcast',$broadcast);
//显示模板
$smarty->display('index.htm');
?>index.htm
<HTML>
smarty显示的信息:{<broadcast>}
</HTML>
<?php
require ('./comm/smarty.class.php');
define ('_SITE_ROOT','E:/smarty');
$tp1=new smarty();
$tp1->template_dir=_SITE_ROOT.'/templates/';
$tp1->template_c=_SITE_ROOT.'/templates_c/';
$tp1->config_dir=_SITE_ROOT.'/configs/';
$tp1->cache_dir=_SITE_ROOT.'/cache/';
$tp1->left_delimiter='{';
$tp1->right_delimiter='}';
?>test.php文件如下
<?php
require ('main.php');
global $tp1;
$tp1->assign('title','测试用的网页');
$tp1->assign('content','测试用的网页内容');
$tp1->display('test1.html');
?>
test1.html如下显示
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
{$title}
<br/>
{$content}
</BODY>
</HTML>