• 夺命雷公狗---Smarty NO:09 ldelim–rdelim—literal函数


    ldelim、rdelim函数

    功能:输出左右分隔符

    基本语法:

    {ldelim}

    {rdelim}

    demo4.php示例代码:

    <?php
    require “smarty/Smarty.class.php”;
    $smarty = new Smarty();
    $title = ‘hello';
    $smarty -> assign(‘title’,$title);
    $smarty -> display(“demo4.html”);

    demo4.html

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset=’utf-8′>
    <title></title>
    </head>
    <body>
    <h1>test</h1>
    <div>smarty中的基本标识符为{},我们在定义变量时可以通过{ldelim}$title{rdelim}的形式定义</div>
    </body>
    </html>

    literal函数

    功能:literal 标签区域内的数据将被当作文本处理,此时模板将忽略其内部的所有字符信息. 该特性用于显示有可能包含大括号等字符信息的css或 javascript 脚本. 当这些信息处于 {literal}{/literal} 标签中时,模板引擎将不分析它们,而直接显示.

    demo4.html示例代码:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset=’utf-8′>
    <title></title>
    {literal}
    <style type=”css/text”>
    h1{color:red; font-size:30px;}
    div{color:blue; font-size:24px;}
    </style>
    {/literal}
    </head>
    <body>
    <h1>test</h1>
    <div>test</div>
    </body>
    </html>

    demo4.php示例代码:

    <?php
    require “smarty/Smarty.class.php”;
    $smarty = new Smarty();
    $smarty -> display(“demo4.html”);
  • 相关阅读:
    centos6.5下的mysql5.6.30安装
    mysql常见错误
    fpm打包redis3.0.7
    centos6.5安装fpm打包工具
    centos6.5安装flume
    centos6.5 安装mono
    利用rsyslog 对linux 操作进行审计
    CentOS7修改服务器主机名方法
    CentOS 7 修改网卡名称为eth
    keepalived配置日志
  • 原文地址:https://www.cnblogs.com/leigood/p/5033236.html
Copyright © 2020-2023  润新知