Home >
Article > Backend Development > Can tags in php be used in smarty? For example:
The PHP framework I wrote myself uses SMARTY as the template engine. Do I still need to encapsulate PHP tags?
The PHP framework I wrote myself uses SMARTY as the template engine. Do I still need to encapsulate PHP tags?
You can use any php function in smarty 3
<code>{$data|json_encode} {json_encode($data)} {$data->toString()}</code>
For if, foreach and the like, smarty itself has it
<code>{if $a == 1} ... {else} ... {/if} {foreach $data as $item} ... {foreachelse} ... {/foreach}</code>
If you want to customize modifiers, functions, labels, etc., please check the manual and reference folder:
<code>smarty/libs/plugins/</code>
For example, you can customize the function: {template_include file=""}