PHP之ThinkPHP模板標籤操做

Action    :this

$User=M("user");
     $list=$User->select();
     $this->assign("list",$list);
     $this->assign("index",1);
     $this->display();spa

 

前臺模板標籤it

<h1>volist</h1>io

<table>
<tr>
  <td>ID</td><td>UserName</td><td>Sex</td><td>Age</td>
</tr>
<volist name="list" id="item">
<tr>
  <td>{$item["id"]}</td><td>{$item["username"]}</td><td>{$item["sex"]}</td><td>{$item["age"]}</td>
</tr>
</volist>
</table>table


<hr>模板

<h1>foreach</h1>
<table>
<tr>
  <td>ID</td><td>UserName</td><td>Sex</td><td>Age</td>
</tr>
<foreach name="list" item="item">
<tr>
  <td>{$item["id"]}</td><td>{$item["username"]}</td><td>{$item["sex"]}</td><td>{$item["age"]}</td>
</tr>
</foreach>
</table>foreach


<h1>switch</h1>
<switch name="index">
  <case value="1" >1</case>
  <case value="0">0</case>
</switch>select


<h1>if</h1>
<if condition="$index==1">1
 <elseif condition="$index==2"/>2
  <else/>0
</if>tab

相關文章
相關標籤/搜索