内建函数是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}>

  

相关文章:

  • 2022-01-19
  • 2021-06-22
  • 2021-08-23
  • 2021-07-10
  • 2022-02-21
  • 2021-05-29
猜你喜欢
  • 2022-12-23
  • 2021-10-09
  • 2021-05-20
  • 2021-09-11
  • 2022-12-23
  • 2021-12-10
相关资源
相似解决方案