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

WBOY
Release: 2016-10-10 11:56:26
Original
1335 people have browsed it

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>
Copy after login

For if, foreach and the like, smarty itself has it

<code>{if $a == 1}
...
{else}
...
{/if}

{foreach $data as $item}
...
{foreachelse}
...
{/foreach}</code>
Copy after login

If you want to customize modifiers, functions, labels, etc., please check the manual and reference folder:

<code>smarty/libs/plugins/</code>
Copy after login

For example, you can customize the function: {template_include file=""}

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template