Home > Backend Development > PHP Tutorial > How to use the built-in functions if, elseif and else in smarty template engine, smartyelseif_PHP tutorial

How to use the built-in functions if, elseif and else in smarty template engine, smartyelseif_PHP tutorial

WBOY
Release: 2016-07-13 10:09:15
Original
1050 people have browsed it

How to use the built-in functions if, elseif and else in smarty template engine, smartyelseif

The examples in this article describe the use of smarty’s built-in functions if, elseif and else, and share them with you for your reference. The details are as follows:

Template file: temp.tpl

Copy code The code is as follows:

Usage of smarty built-in functions if, elseif and else

Example 1——>Use of if: Remove key values ​​whose key names are not equal to c3 and n3


{foreach from=$arr4 item=temp}
{foreach from=$temp item=value key=k}
{if $k neq "c3" and $k neq "n3"}
{$k}={$value}
{/if}
{/foreach}

{/foreach}

Example 2——>Usage of elseif: If it is a beautiful woman, output one sentence, otherwise output another sentence


{foreach from=$arr4 item=temp}
{foreach from=$temp item=value key=k}
{if $value eq "Beauty"}
You are a beauty
{else}
You are all handsome guys
{/if}
{/foreach}
{/foreach}

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/946749.htmlTechArticleHow to use the built-in functions if, elseif and else in smarty template engine, smartyelseif This article describes the smarty built-in function in an example The usage of functions if, elseif and else is shared with everyone for your reference...
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