zoukankan      html  css  js  c++  java
  • 【ThinkPHP框架3.2版本学习总结】四、视图

    1. 模板文件的定义

    2. 设置模板的后缀名称

    3. 视图分隔符

    4. 模板注释

    {/* 注释内容 */ } :多行注释
    {// 注释内容 } :单行注释

    5. 模板输出

    (1)display方法

    流程:读取模板文件——替换变量——输出内容

    (2)fetch方法

    流程:读取模板文件——替换变量——获取内容

    6. 变量输出

    (1)普通变量

    定义方式:

    输出方式:

    (2)数组变量

    定义方式:

    输出方式:

    (3)对象变量

    定义方式:

    输出方式:

    7. 系统变量

    $Think.server :相当于PHP代码中$_SERVER[‘变量名称’];
    $Think.get :$_GET[];
    $Think.post :$_POST[];
    $Think.request :$_REQUEST[];
    $Think.cookie :$COOKIES[];
    $Think.session :$_SESSION[];
    $Think.config :读取配置文件信息

    8. 使用原生函数

    9. 默认值

    10. 运算符

    +   {$a+$b}
    -   {$a-$b}
    *   {$a*$b}
    /   {$a/$b}
    %   {$a%$b}
    ++  {$a++} 或 {++$a}
    --  {$a--} 或 {--$a}

    11. include文件包含

    12. import文件导入

    起始路径是网站的Public目录,采用命名空间方式,资源文件类型,默认为js

    13. volist遍历数组

    基本语法:

    <volist name="list" id="vo">
        {$vo.id}
        {$vo.name}
    </volist>

    参数说明:

    name(必须):要遍历的数组变量
    id(必须):当前数组元素
    offset:要输出数据的offset
    length:输出数据的长度,需要指定offset
    key:循环索引(默认从1开始)

    14. foreach遍历数组

    基本语法:

    <foreach name="list" item="vo" >
        {$vo.id}
        {$vo.name}
    </foreach>

    参数说明:

    name(必须):要遍历的数组变量
    item(必须):当前数组元素

    foreach与volist都是遍历数组,效果相同,只是foreach没有附加属性

    15. if条件判断

    基本语法:

    <if condition='条件'>
        <elseif condition='条件' />
        <else/>
    </if>

  • 相关阅读:
    CodeForces 659F Polycarp and Hay
    CodeForces 713C Sonya and Problem Wihtout a Legend
    CodeForces 712D Memory and Scores
    CodeForces 689E Mike and Geometry Problem
    CodeForces 675D Tree Construction
    CodeForces 671A Recycling Bottles
    CodeForces 667C Reberland Linguistics
    CodeForces 672D Robin Hood
    CodeForces 675E Trains and Statistic
    CodeForces 676D Theseus and labyrinth
  • 原文地址:https://www.cnblogs.com/chenjiacheng/p/6522292.html
Copyright © 2011-2022 走看看