我自己写的php框架,使用smarty作为模板引擎,还用封装php标签吗?
我自己写的php框架,使用smarty作为模板引擎,还用封装php标签吗?
smarty 3中可以使用任何php的函数
<code>{$data|json_encode}
{json_encode($data)}
{$data->toString()}</code>对于if,foreach之类的,smarty自身就有
<code>{if $a == 1}
...
{else}
...
{/if}
{foreach $data as $item}
...
{foreachelse}
...
{/foreach}</code>如果要自定义modifier,或者函数,标签等,还麻烦查看手册,以及参考文件夹:
立即学习“PHP免费学习笔记(深入)”;
<code>smarty/libs/plugins/</code>
比如,可以自定义函数:{template_include file=""}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号