zoukankan      html  css  js  c++  java
  • PHP中Smarty引擎的常用语法

    PHP中Smarty引擎的常用语法

    输出今天的日期:

    {$smarty.now|date_format:"%H:%M %A, %B %e, %Y"}

    实际上用到了PHP的time()函数

    明天Date of Tomorrow:

    {"tomorrow"|date_format:"%A, %B %e, %Y"}

    后天Date of the day after tomorrow (Day+2):

    {"+2 days"|date_format:"%A, %B %e, %Y"}

    (Day+3):

    {"+3 days"|date_format:"%A, %B %e, %Y"}

    相关链接:

    How to do to print out date of tomorrow (day+1) with Smarty? - v1.x Store Design & Templates - CS-Cart Community Forums http://forum.cs-cart.com/topic/8070-how-to-do-to-print-out-date-of-tomorrow-day1-with-smarty/

    foreach

        {foreach from=$workDetails key=key item=workDetail}
            <td>{$workDetail['name']}</td>
        {/foreach}

    if, else

    {if $weekDay neq 0 and  $weekDay neq 6}
    
    {else}
    
    {/if}

    调用php函数

    {$monthDay|substr:'5':'9'}

    {if $weekDay neq 0 and  $weekDay neq 6}
        <th>
            <div style="text-align: center; {$tableTdWidth * ($groupMaxCostData['groupMaxCostTimes'][$monthDay] + 1)}px">{$monthDay|substr:'5':'9'}<div>
        </th>
    {else}
        <th style="background-color: gray;">
            <div style="{$tableTdWidth * ($groupMaxCostData['groupMaxCostTimes'][$monthDay] + 1)}px">{$monthDay|substr:'5':'9'}<div>
        </th>
    {/if}

    相等与不等

    eq、neq
    和shell的写法接近

    $var eq 5

    是否有值

    {if $var}
  • 相关阅读:
    Go map 切片
    Go map 增删改查和遍历
    Go map 基本使用
    Go 二维数组
    Go 切片
    Go 数组
    Go 错误处理 defer recover panic
    Go time模块
    5分钟入门MP4文件格式
    写盘工具
  • 原文地址:https://www.cnblogs.com/enjoy233/p/10408786.html
Copyright © 2011-2022 走看看