zoukankan      html  css  js  c++  java
  • 夺命雷公狗---Smarty NO:05 设计篇3 变量调节器

    {$var|date_format:”%Y%m%d”} :时间格式化,%Y-%m-%d %H:%M:%S

    {$var|default:”value”} :当变量为空时,设置默认值

    {$var|escape} :html转码

    {$var|indent:10:”*”} :字符缩进

    {$var|lower} :转小写

    {$var|upper} :转大写

    {$var|nl2br} :把 转化为br标签

    demo3.html

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset=’utf-8′>
    <title></title>
    </head>
    <body>
    当前系统事件:{$smarty.now|date_format:”%Y-%m-%d %H:%M:%S”}
    <hr/>
    默认值:{$val|default:’未查询到该变量’}
    <hr/>
    escape转码:{$str3|escape}
    <hr/>
    Indent字符缩进:{$str|indent:10:’*’}<!–这里的*好是代替字符–>
    <hr/>
    转大写:{$str|upper}
    <hr/>
    nl2br:{$str|nl2br}<!–将变量值中的”
    ”回车全部转换成HTML的 <br />–>
    <hr/>
    </body>
    </html>

    demo3.php

    <?php
    require “smarty/Smarty.class.php”;
    $smarty = new Smarty();
    $str = “hello world”;
    $str2 = “nihao php”;
    $str3 = “<ul><li>hello ul li</li></ul>”;
    $smarty -> assign(‘str’,$str);
    $smarty -> assign(‘str2′,$str2);
    $smarty -> assign(‘str3′,$str3);
    $smarty -> display(“demo3.html”);
  • 相关阅读:
    Balanced Binary Tree
    Swap Nodes in Pairs
    Reverse Nodes in k-Group
    Reverse Linked List II
    Remove Nth Node From End of List
    Remove Duplicates from Sorted List II
    Remove Duplicates from Sorted List
    Partition List
    Merge Two Sorted Lists
    【Yii2.0】1.2 Apache检查配置文件语法
  • 原文地址:https://www.cnblogs.com/leigood/p/5033067.html
Copyright © 2011-2022 走看看