php - smarty中可以将函数调用结果存入变量吗?
怪我咯
怪我咯 2017-04-10 13:12:47
0
1
467

项目中有个需求:提供了一个php函数,返回bool值,而且这个函数已经register到smarty模板中,模板中要调用这个函数,并根据返回结果判断显示什么内容,smarty中可以将函数调用结果存入变量吗?

怪我咯
怪我咯

走同样的路,发现不同的人生

Antworte allen(1)
PHPzhong

哈哈,自已搞定了,例子如下:

<{php}>
$this->assign('result', api('ip.client_ip'));
<{/php}>

<{$result}>

参考:http://www.smarty.net/docs/en/languag...

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage