四,Smarty模板技术/引擎-----内建函数

内建函数是smarty提供的函数,不允许修改,只能被调用;

自定义函数是自己编写函数,注册成为smarty的函数,之后可以被调用。

PHP的自建函数很多,讲解下<foreach>和<if>。

1,foreach

一维数组:
<{foreach from=$arr1 item=arrOne }>
    <{$arrOne}>
<{/foreach}>
<br/>
二维数组
<{foreach from=$arr3 item=arrOne}>
    <{foreach from=$arrOne item=cell}>
        <{$cell}>
    <{/foreach}>
<br/>
<{/foreach}>
<br/>

2,if

<{if $age > 10}>
年龄大于10
<{else}>
年龄小于10
<{/if}>

  

<{if $age < 5}>
小孩
<{elseif $age >5 and $age <10}>
年轻人
<{else}>
成年人
<{/if}>

  

原文地址:https://www.cnblogs.com/usa007lhy/p/4961682.html