Home  >  Article  >  Backend Development  >  Can tags in php be used in smarty? For example: etc.

Can tags in php be used in smarty? For example: etc.

WBOY
WBOYOriginal
2016-10-10 11:56:261334browse

The PHP framework I wrote myself uses SMARTY as the template engine. Do I still need to encapsulate PHP tags?

Reply content:

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=""}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn