zoukankan      html  css  js  c++  java
  • Smarty变量

    变量

    内容列表

    $template_dir [模板目录变量]

    [从PHP分配的变量]

    [从配置文件读取的变量]

    [{$smarty} 保留变量]

    Smarty有几种不同类型的变量.

    变量 的类型取决于它的前缀是什么符号(或者被什么符号包围)

    Smarty的变量可以直接被输出或者作为函数属性和修饰符(modifiers)的参数,或者用于内部的条件表达式等等.

    如果要输出一个变量,只要用定界符将它括起来就可以.例如:

     

     
    {$Name} 
    
    {$Contacts[row].Phone}
    
    <body bgcolor="{#bgcolor#}">

     

     

    从PHP分配的变量

    内容列表

    关联数组

    数组下标

    对象

     

    调用从PHP分配的变量需在前加"$"符号.(译注:同php一样)
    调用模板内的assign函数分配的变量也是这样.(译注:也是用$加变量名来调用)


    例 4-1.分配的变量

    index.php:
    
    
    $smarty = new Smarty;
    $smarty->assign('firstname', 'Doug');
    $smarty->assign('lastLoginDate', 'January 11th, 2001');
    $smarty->display('index.tpl');
    
    index.tpl:
    
    Hello {$firstname}, glad to see you could make it.
    <p>
    Your last login was on {$lastLoginDate}.
    
    OUTPUT:
    
    Hello Doug, glad to see you could make it.
    <p>
    Your last login was on January 11th, 2001.
  • 相关阅读:
    Spring IoC详解
    Hibernate 和Mybatis的区别
    Nand Flash 驱动框架
    Nor Flash 驱动框架
    USB驱动框架
    输入子系统框架
    module_init 内核调用过程
    平台设备驱动框架
    LCD驱动框架
    嵌入式-开篇
  • 原文地址:https://www.cnblogs.com/danmao/p/4297503.html
Copyright © 2011-2022 走看看