$tpl = new Smarty(); 
 $arr=$_SERVER;
 $tpl->assign("arr", $arr); 
我在模板中设定{$arr.SERVER_NAME}想获得数组$arr['SERVER_NAME']中的值可就是没有结果,我用echo 打印是有结果的哦不知那里出错了

 

解决方案 »

  1.   

    /*0117.php*/
    <?php
    require_once('lib/MySmarty.php');
    $tpl= new MySmarty(); 
    $arr=$_SERVER; 
    $tpl-> assign("arr",$arr);   
    $tpl->display("0117.html");
    ?>/*0117.html*/
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT=""></HEAD><BODY>
    {{$arr.SERVER_NAME}}
    </BODY>
    </HTML>