• smarty函数


    内置函数(重要的几个):
    <{html_checkboxes name='nation' values=$code output=$name selected=$selid separator='<br />'}>//复选框
    <{html_options name='ceshi' options=$xuanxiang selected=$selids}>//下拉列表
    <{html_select_date start_year="1990" end_year="2020" month_format="%m" field_order="YMD" field_array="aa"}>//日期
    <{html_select_time use_24_hours=true}>//时间
    自定义函数:
    1、<{jiandan cishu=10 neirong='hello'}>//函数调用
    function.jiandan.php  //文件
    <?php
    function smarty_function_jiandan($args)//$args是一个数组,不是可变函数,参数以数组形式传入
    {
        //1.循环次数 cishu
        //2.循环内容 neirong
        //array('cishu'=>10,'neirong'=>'hello')    
        $num = $args["cishu"];
        $neirong = $args["neirong"];    
        $str = "";    
        for($i=0;$i<$num;$i++)
        {
            $str = $str.$neirong;
        }    
        return $str;    
    }
    
    

    2、块函数--》写法,调用两次,标识
    <{biaoji size=24}>    //size是参数
        hello world    //$content
    <{/biaoji}>      
    block.biaoji.php //文件

    <?php
    function smarty_block_biaoji($args,$content,$smarty,$bs)
    {
        //return "aa---{$content}--{$bs}<br>";    输出页面上试试,标识-->是否是第一次调用
        if(!$bs)
        {
            $size = $args["size"];
            $content = "<mark style='font-size:{$size}px'>{$content}</mark>";
            return $content;
        }
    
    }

    3、自带控件:
    <{textarea name='editer' toolbar='full' height=300 color=red}><{/textarea}>
    block.textarea.php
    <{color name='color' value='#000000'}>
    function.color.php
    <{date name='riqi' value='2016-7-24' time=1}>
    function.date.php
    //自己建相应的文件

     
  • 相关阅读:
    TIDB-存储
    MySQL的ACID
    MySQL MVCC
    MySQL 悲观锁、乐观锁、MVCC一
    MySQL写放大总结
    基于Linux上的wifi密码爆破
    Stack与Queue的实现(c++模板实现)
    vector 实现二维数组
    Linux下的静态链接与动态链接
    260. Single Number III
  • 原文地址:https://www.cnblogs.com/jinshui/p/5701179.html
Copyright © 2020-2023  润新知