zoukankan      html  css  js  c++  java
  • smarty精品教程三(高级篇)

    接下来我们学习smarty数组.

    eg3:

    3.php

    <?php
    /*********************************************
    QQ:283093141

    *********************************************/
    include_once('../libs/Smarty.class.php');   //包含smarty类文件

    $smarty= new Smarty;  //实例化Smarty类

    $smarty->template_dir= './templates';  //设置模板目录
    $smarty->compile_dir= './templates_c';      //设置编译目录
    $smarty->cache_dir= './cache';              //设定缓存目录
    $smarty->caching = ture;

    //--------------------------------------------------------------------------------------
    //处理{html_checkboxes name="CheckBox" values=$CheckName checked=$IsChecked output=$value separator="<br />"}
    //--------------------------------------------------------------------------------------
    $smarty->assign('CheckName', array(
    1001 => '我',
    1002 => '爱',
    1003 => '你'));
    $smarty->assign('IsChecked', 1001);


    //--------------------------------------------------------------------------------------
    //处理{html_radios name="RadioBox" values=$RadioName checked=$IsChecked output=$value separator="<br />"}
    //--------------------------------------------------------------------------------------
    $smarty->assign('RadioName', array(
    1001 => '你',
    1002 => '爱',
    1003 => '我',
    1004 => '吗?'));
    $smarty->assign('IsChecked', 1002);

    //--------------------------------------------------------------------------------------
    //{html_select_date}不用处理会自动输出
    //--------------------------------------------------------------------------------------

    $smarty->display("3/3.tpl");
    ?>

    3.tpl

    <html>
    <head><title>模板中内定的一些函数</title></head>
    <body>

    {*下面的这一段相当于在模板内部定义一个变量UserName*}
    {assign var="UserName" value="fkedgwy"}
    显示模板内部定义的一个变量:UserName = {$UserName}<br>

    显示3个多选框:<br>
    {html_checkboxes options=$CheckName values=$CheckName checked=$IsChecked output=$value separator="<br />"}

    显示3个单选项框:<br>
    {html_radios options=$RadioName values=$RadioName checked=$IsChecked output=$value separator="<br />"}


    显示一个月,日, 年选择框:<br>
    {html_select_date}

    <hr><b> By fkedwgwy 2008<b><a href="http://fkedwgwy.51.com" >作者</a>

    </body>
    </html>

    这就是smarty数组的运用,简单吧`````

  • 相关阅读:
    LeetCode 769. Max Chunks To Make Sorted
    LeetCode 845. Longest Mountain in Array
    LeetCode 1059. All Paths from Source Lead to Destination
    1129. Shortest Path with Alternating Colors
    LeetCode 785. Is Graph Bipartite?
    LeetCode 802. Find Eventual Safe States
    LeetCode 1043. Partition Array for Maximum Sum
    LeetCode 841. Keys and Rooms
    LeetCode 1061. Lexicographically Smallest Equivalent String
    LeetCode 1102. Path With Maximum Minimum Value
  • 原文地址:https://www.cnblogs.com/fengju/p/6174138.html
Copyright © 2011-2022 走看看