在php和模板使用中,前辈们建议使用smarty。于是下载了smarty,并且简单阅读了手册,觉得不够过瘾,然后又从网上找了个简单使用实例测试。实例很简单也很明了。不过在我电脑上测试无效。代码如下: <?php
//error_reporting(E_ALL);
echo "aaaaaaaaaaa";
require 'libs/Smarty.class.php';
$tpl = new Smarty;
$tpl->template_dir = "templates/";
$tpl->compile_dir = "templates_c/";
//$tpl->config_dir = "config/";
$tpl->cache_dir = "cache/";
$tpl->left_delimiter = "<{";
$tpl->right_delimiter = "}>";
$tpl->assign("title", "this is title");
$tpl->assign("content", "this is content");
$tpl->display('test.htm');
?>当把 $tpl = new Smarty();这一行以及后面的行注销以后,可以显示出aaaaaaaaaaaaaaaa。可是只要用$tpl = new Smarty();一实例化这个类,就会什么都不显示了。
然后我就用error_reporting(E_ALL);开启了错误报告,也是什么都没有显示。网页空空的。test.htm是在templates目录下。
libs即为smarty的目录
请问是什么原因无法实例化这个类?
//error_reporting(E_ALL);
echo "aaaaaaaaaaa";
require 'libs/Smarty.class.php';
$tpl = new Smarty;
$tpl->template_dir = "templates/";
$tpl->compile_dir = "templates_c/";
//$tpl->config_dir = "config/";
$tpl->cache_dir = "cache/";
$tpl->left_delimiter = "<{";
$tpl->right_delimiter = "}>";
$tpl->assign("title", "this is title");
$tpl->assign("content", "this is content");
$tpl->display('test.htm');
?>当把 $tpl = new Smarty();这一行以及后面的行注销以后,可以显示出aaaaaaaaaaaaaaaa。可是只要用$tpl = new Smarty();一实例化这个类,就会什么都不显示了。
然后我就用error_reporting(E_ALL);开启了错误报告,也是什么都没有显示。网页空空的。test.htm是在templates目录下。
libs即为smarty的目录
请问是什么原因无法实例化这个类?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title><{$title}></title>
</head>
<body>
<{$content}>
</body>
</html>