<?php
/* 定义服务器的绝对路径 */
define('BASE_PATH',$_SERVER['DOCUMENT_ROOT']);
/* 定义Smarty目录的绝地你路径 */
define('SMARTY_PATH','\1\system\smarty\\');
/* 加载Smarty类库文件 */
require BASE_PATH.SMARTY_PATH.'Smarty.class.php';
//require 'D:\zhongyaowenjian\huanjing\wamp\www\1\system\smarty\Smarty.class.php';这个不能识别
/* 实例化一个Smarty对象 */
$smarty = new Smarty;
/* 定义各个目录的路径 */
$smarty->template_dir = BASE_PATH.'\1\system\templates/';
$smarty->compile_dir = BASE_PATH.'\1\system\templates_c/';
$smarty->config_dir = BASE_PATH.'\1\system\configs/';
$smarty->cache_dir = BASE_PATH.'\1\system\cache/';
/* 定义定界符 */
$smarty->left_delimiter = '<{';
$smarty->right_delimiter = '}>';?>
上面这是我的配置文件
下面是我的tpl文件
<body>
<{php}> echo "aaaaaaaaaaaaaaaaaaaaa";<{/php}><{$content}>
<div class="badoo"><{$ccc}></div><hr />
</body>
</html>
aaaaaaaaaaa不能显示啊

解决方案 »

  1.   

    木有的事儿,是不是目录路径不对啊。
    改成这样的 BASE_PATH.'\1\system\templates/';----》'd:/a/b/c/templates';
      

  2.   

    那我的section是好使的,就是在tpl文件中php代码错误
      

  3.   

    linux下目录要使用/而不是\
    windows下以/或\开头没有意义
    输出$_SERVER['DOCUMENT_ROOT']看看是什么内容
      

  4.   


    <?php
    include_once("../smarty_config.php"); //注意是否加载$array[] = array("name"=>"Pake","age"=>"22");
    $array[] = array("name"=>"Smith","age"=>"25");//设置模板
    $smarty->assign("title","一个简单smarty模板应用"); //第一个参数为要模板化的元素,第二个为模板化的元素内容//设置数组模板
    $smarty->assign("arr",array("name"=>"Tom","age"=>"20"));
    $smarty->assign("array",$array); //二维数组的应用//将模板应用于文件
    //$smarty->display("../templates/test.html");
    $smarty->display("testOne.html");?>
    <!-- testOne.html -->
    <body>
    <b>
    {$arr['name']}
    &nbsp;|&nbsp;
    {$arr['age']}
    </b><br/>
    <b>
    {$array[0]['name']}
    &nbsp;|&nbsp;
    {$array[0]['age']}
    </b><br/>
    <hr width="150px" align="left" />
    <b>
    {section name=code loop=$array}
    {$array[code].name} &nbsp;|&nbsp;
    {$array[code].age} <br/>
    {/section}
    </b><br/>
     </body>
      

  5.   


    //显示结果
    Tom  |  20 
    Pake  |  22 --------------------------------------------------------------------------------
    Pake  |  22 
    Smith  |  25