2013-07-10 67 views
0

我後我的代碼在這裏第一smarty3顯示器不工作

的index.php:

<?php 
require('class/smarty/Smarty.class.php'); 
$smarty = new Smarty; 

$smarty->setTemplateDir('./templates/'); 
$smarty->setCompileDir('./template_c/'); 
$smarty->setCacheDir('./cache/'); 
$smarty->setConfigDir('./configs/'); 

$smarty->assign('name','Dan Brown'); 
$smarty->display('tpl_1.tpl'); 
?> 

模板文件,tpl_1.tpl:

<!DOCTYPE HTML> 
<html> 
<head> 
<meta charset="UTF-8"> 
<title>demo/title> 
</head> 
<body> 
<h1> 
hello,{$name} 
</h1> 
</body> 
</html> 

一切看起來都很好,但結果是輸出空白頁面,smarty無法顯示或調用模板文件,我的代碼中哪裏出錯。 我真的搞不清這個問題,浪費了太多的時間

回答

0

試試這個,

<?php 
require('class/smarty/Smarty.class.php'); 
$smarty = new Smarty(); 

$smarty->setTemplateDir('./templates/'); 
$smarty->setCompileDir('./template_c/'); 
$smarty->setCacheDir('./cache/'); 
$smarty->setConfigDir('./configs/'); 

$smarty->assign('name','Dan Brown'); 
$smarty->display('tpl_1.tpl'); 
?>