日期:2014-05-17  浏览次数:20372 次

我这个smarty配置怎么了
目录结构如下: smarty_pro1
  ---libs
  ---config
  ---templates (这里放了个,index.tpl)
  ---templates_c
  ---cache
  index.php

index.php 里的内容为
<?php 
define('SMARTY_PATH','../smarty_pro1/');
include_once(SMARTY_PATH.'libs/Smarty.class.php');

$smarty=new Smarty();

$smarty->template_dir= SMARTY_PATH.'templates/';
$smarty->compile_dir= SMARTY_PATH.'templates_c/';
$smarty->config_dir= SMARTY_PATH.'configs/';
$smarty->cache_dir= SMARTY_PATH.'cache/';

$smarty->left_delimiter='{';
$smarty->right_delimiter='}';
$smarty->assign('title','测试一下');
$smarty->assign('content','内容');
$smarty->display('index.tpl');


?>

index.tpl内容为

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>{ $title }</title>
</head>

<body>
{ $content }
</body>
</html>

为什么结果 这里面的两个变量都没有得到值啊,搞了好久也没搞好,是什么问题啊?

------解决方案--------------------
PHP code
$smarty->left_delimiter='{ '; // 注意引号中的空格
$smarty->right_delimiter=' }'; // 注意引号中的空格

------解决方案--------------------
探讨
PHP code
$smarty->left_delimiter='{ '; // 注意引号中的空格
$smarty->right_delimiter=' }'; // 注意引号中的空格


如果你非常喜欢在{}加空格的话,那么请告诉smarty你的习惯!