thinkphp6模板变量调用函数
PHP 2022/6/23 14:56:50 点击:不统计
thinkphp6模板中如何调用函数,变量通过模板中的函数处理,thinkphp6模板中变量如果使用多参数处理
首先看单参数变量函数处理
比如参数 $forasp = "thinkphp6's trim ";
在模板tpl中使用 trim 函数 去除空格
{$forasp|trim}
结果显示 “thinkphp6's strip”
其次如果是函数有多个变量的时候,比如str_replace 那么在模板中怎么输出呢
比如参数 $forasp = "thinkphp6's trim ";
在模板tpl中使用 str_replace 函数 替换 strip 为good
{$forasp|str_replace="strip","good",###}
结果显示 “thinkphp6's good "
就是用### 来替换我们的变量。
最后是如果是多个函数连续使用 则需要用|进行链接
比如上面的两个函数相继使用
{$forasp|trim|str_replace="strip","good",###}
转www.载for网站制作学习asp必.cn究