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

Source: Internet
Author: User
The usage of built-in functions such as if, elseif, and else in the smarty template engine is smartyelseif. The usage of the built-in functions if, elseif, and else in the smarty template engine. This document describes how to use the built-in functions if, elseif, and else in smarty, we will share with you how to use the built-in functions if, elseif, and else in the smarty template engine.

This article describes how to use the built-in functions of smarty, such as if, elseif, and else. 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.

Examples in this article describes how to use the built-in functions of smarty, such as if, elseif, and else...

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.