Basic syntax of php template engine smarty

Source: Internet
Author: User
In the smarty template, both built-in and custom functions have the same syntax. annotation
The template comment is surrounded by the asterisk (*) in the format of {* this is a comment *}
Example: {* Smarty annotation Www.php118.com*} {* Include the header file here *} {include file = "header. tpl"} {* display dropdown lists *} {Html_options values = $ vals selected = $ selected output = $ output}

Function
In the smarty template, both built-in and custom functions have the same syntax.
Built-in functions will work within smarty, such as {if}, {section}, and {strip}. they cannot be modified.
UDFs work through the plug-in mechanism. they are additional functions. you can modify them as you like. you can also add them as needed.
For example, {html_options} and {html_select_date}
Function syntax: {funcname attr1 = "val" attr2 = "val "}
Most functions have their own parameters to regulate and modify their behavior.
The static values of functions in the smarty template engine do not need to be enclosed by quotation marks, but strings must be added.
Variables are referenced when values are assigned, and no quotation marks are required.
Code snippet:
{Html_select_date display_days = yes} {Html_options values = $ vals selected = $ selected output = $ output}As shown in the preceding figure, if the parameter is a Boolean value, double quotation marks are not required.

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.