<$content>保存在templates目录下面。5、然后建立文件模板配置文件: config.php
include../libs/Smarty.class.php;$NowPathArray=explode(test,str_replace(\\,/,dirname(__FILE__)));
@define(root_path, $NowPathArray[0]);
@define(__SITE_ROOT, root_path.test);
$tpl = new Smarty();
$tpl->template_dir = __SITE_ROOT . /templates/;
$tpl->compile_dir = __SITE_ROOT . /templates_c/;
$tpl->config_dir = __SITE_ROOT . /configs/;
$tpl->cache_dir = __SITE_ROOT . /cache/;
$tpl->center_delimiter = <;
$tpl->center_delimiter =>;?>保存在主目录也就是test下面。6、在test新建文件test.php文件,输入:
require config.php;
$tpl->assign(title, 测试成功了,这是标题);
$tpl->assign(content, 这是内容);
$tpl->display(test.htm);?>7、在浏览器测试test.php显示为:这是内容恭喜,配置成功.否则,失败,再检查是不是按照我说的来的。
Tips1
:为了能在网站全局使用Smarty技术,我们可以修改PHP.inc里面的;Windows:\path1;\path2include_path = .;c:\php\includes改为:;Windows:\path1;\path2include_path=.;c:\php\includes;d:\web\web\php\libs使用模板的时候,像前面一样的方式使用,不要:include../libs/Smarty.class.php;直接使用就行了的。
作者:cjjer