Use of built-in functions such as if, elseif, and else In the smarty template engine

Source: Internet
Author: User
This article describes how to use the built-in functions of the smarty template engine, such as if, elseif, and else. It uses two examples to analyze the usage skills of if, elseif, and else. For more information, see

This article describes how to use the built-in functions of the smarty template engine, such as if, elseif, and else. It uses two examples to analyze the usage skills of if, elseif, and else. For more information, see

This article describes how to use elp, makewebs, php, 2014042592404.html "> smartyelp, makewebs, asks, 2014042090164.html"> built-in functions if, elseif, and else for your reference. The details are as follows:

Template File: temp. tpl

The Code is as follows:


Use of smarty built-in functions such as if, elseif, and else

Instance 1 --> Use of if: retrieve key values other than 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 --> Use of elseif: if it is a beauty, output a sentence, otherwise output another sentence


{Foreach from = $ arr4 item = temp}
{Foreach from = $ temp item = value key = k}
{If $ value eq ""}
You are a pretty girl
{Else}
You are all handsome guys.
{/If}
{/Foreach}
{/Foreach}

I hope this article will help you with php programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.