et的新功能,其实et都有了,我这里复制一下,这样好记些 不指定

Else , 2008/06/06 01:38 , 工蚁的忙碌工作 , Comments(0) , Reads(1242) , Via Original
利用模板函数writer功能来写入文件cache_htm/test.htm


<?php  
    chdir('../../');            //指定到根目录  
    include"template.php";      //Ease Template  
    $tl = new template();    
      
    include"example/files.php"; //Source Code  
      
    $wfile = 'cache_htm/test.htm';  
    $data  = '测试ET写入数据功能!';  
    $data  = $tl->writer($wfile,$data);   PHP:example/et_d/1.php
<?php  
    chdir('../../');            //指定到根目录  
    include"template.php";      //Ease Template  
    $tl = new template();    
      
    include"example/files.php"; //Source Code  
      
    $rfile = 'example/et_d/1.php';  
    $data  = $tl->reader($rfile);  
      
    $tl->set_file('et_d1');  
    $tl->p();  
      
?>  

[code]<?php
  chdir('../../');      //指定到根目录
  include"template.php";    //Ease Template
  $tl = new template();
  
  include"example/files.php";  //Source Code
  
  $rfile = 'example/et_d/1.php';
  $data  = $tl->reader($rfile);
  
  $tl->set_file('et_d1');
  $tl->p();
  
?>

HTM:template/et_d1.htm

利用模板函数reader功能来读取文件{rfile}

  

得到的结果如下:

  

{data}

  


      
    $tl->set_file('et_d2');  
    $tl->p();  
      
?>  [/code]

HTM:template/et_d2.htm

<p>利用模板函数writer功能来写入文件{wfile}</p>  
<p>写入内容为:{data}</p>  
<p><a href="../../cache/test.htm" target=_blank>点此访问写入数据内容</a></p>  


利用模板函数reader功能来读取文件example/et_d/1.php

得到的结果如下:

reader($rfile); $tl->set_file('et_d1'); $tl->p(); ?>




<?php  
    chdir('../../');            //指定到根目录  
    include"template.php";      //Ease Template  
    $tl = new template();    
      
    include"example/files.php"; //Source Code  
      
    $tl->set_file('et_c3');  
    $tl->p();  
      
?>  





<?php  
    chdir('../../');            //指定到根目录  
    include"template.php";      //Ease Template  
    $tl = new template();    
      
    include"example/files.php"; //Source Code  
      
      
    $user_list = array(  
        array(  
            'name'    => 'md-chinese',  
            'pass'    => '654321',  
        ),  
        array(  
            'name'    => 'test',  
            'pass'    => '123456',  
        )  
    );  
      
    //最关键的函数就是清除旧数据  
    $tl->clear();  
    unset($K,$V,$showdata);  
    foreach ($user_list AS $key=>$V) {  
        $tl->set_file('et_b7_1');  
        $showdata .= $tl->r();  
    }  
      
      
    $tl->set_file('et_b7');  
    $tl->p();  
      
?>




HTM:template/et_b7_1.htm
  账号:{V['name']}<br>  
  密码:{V['pass']}<br><br>  
  账号:{V['name']}<br>
  密码:{V['pass']}<br><br>
HTM:template/et_b7.htm
<p>测试循环模板并且将结果显示在当前模板中</p>  
<p>{showdata}</p>  
<p>上面为测试循环内容</p>  




<?php  
    chdir('../../');            //指定到根目录  
    include"template.php";      //Ease Template  
    $tl = new template();    
      
    include"example/files.php"; //Source Code  
      
    $cate = array(  
                '分类1' => array('计算机','报纸','杂志','鼠标'),  
                '分类2' => array('青菜','白菜'),  
                '分类3' => array('橘子','香蕉','苹果')  
            );  
      
    $tl->set_file('et_b6');  
    $tl->p();  
      
?>  



嵌套循环:<br>  
<table border="1" width="300"  bordercolor="#C0C0C0">  
<!-- $cate AS $ck=>$cv -->  
    <tr>  
        <td><b>{ck}</b></td>  
    </tr>  
    <!-- $cv AS $V -->  
        <tr>  
            <td>  ->{V}</td>  
        </tr>  
    <!-- END -->  
<!-- END -->  


Tags: ,
Add a comment

Nickname

Site URI

Email

Enable HTML Enable UBB Enable Emots Hidden Remember [Login] [Register]