The example in this article describes the for loop and switch statement usage in the thinkphp template. Share to everyone for your reference, specific as follows:
1.for usage
<for start= "Start value" end= "End Value" comparison= "step=" Step value "Name=" Loop variable name ">
</for>
Case
<for start= "1" end= "M" >
{$i}
</for>
resolves to
For ($i =1 $i <100; $i +=1) {
echo $i;
}
2.switch usage
<switch name= "Variable" >
<case value= "value 1" break= "0 or 1 > Output 1</case> <case value=
" Value 2 "> Output content 2</case>
<default/> Default
</switch>
Case
<switch name= "User.level" >
<case value= "1" >value1</case>
<case value= "2" >value2 </case>
<default/>default
</switch>
You can also use variables for the Value property of the case, for example:
<switch name= "User.userid" >
<case value= "$adminId" >admin</case>
<case value= "$ MemberID ">member</case>
<default/>default
</switch>
Comprehensive case
<for start= "0" end= "$credit [' num ']" >
<switch name= "credit[' Level ']" >
<case value= "1" > </case>
<case value= "2" >< IMG src= "{sh::P ub}img/credit/level-diamond2.png" class= "star" ></case>
<case value= "3" ></case>
<case value= "4" ></case>
<default/>default
</ Switch>
</for>
More interested readers of thinkphp related content can view the website topic: "thinkphp Introductory Course", "thinkphp template Operation Skill Summary", "thinkphp Common Method Summary", "The CodeIgniter Introductory Course", "CI ( CodeIgniter) Framework Advanced tutorials, introductory tutorials for the Zend framework Framework, Smarty Templates Primer tutorial, and PHP template technology summary.
I hope this article will help you with the PHP program design based on thinkphp framework.