Php-smarty-5 (+), phpsmarty-522_php tutorial

Source: Internet
Author: User

Php-smarty-5 (+), phpsmarty-522


Pick up an article

11, Section,sectionelse section is a circular structure statement, mainly used to iterate over an array

Grammar:

{Section name= name loop= Loop Array (number of times) start= start (0) step= Step (1) max= maximum number of cycles}
{Sectionelse}

{/section}

Name: Name required for the section statement

Loop: Circular array required

Start: Start index default value: 0

Step: Default Step Size: 1

Max: Maximum Cycle count default: total length

The difference between foreach and section:

foreach refers to traversing an array directly

A section is a circular statement whose number of loops is determined by the number of arrays

Section has more selectivity in iterating over the array

Built-in Variables for section L

{$smarty. Section.name.index} cyclic Index

{$smarty. Section.name.index_prev} last Loop index

{$smarty. Section.name.index_next} Next Loop index

{$smarty. section.name.iteration} cyclic index starting from 1

{$smarty. section.name.first|last} Both values are true at the time of the 1th and last execution

{$smarty. section.name.total} total number of cycles

12, strip remove the continuous space before and after

Grammar:

{Strip}

......

{/strip}

Ii.. Custom Functions

1. Assign creating template variables

{Assign var= "var" value= "value"}

Var: Specify Variable name

Value: Specify a variable value

2. Counter counter

Grammar:

{Counter start=0 skip=2 Print=false}

Start: The starting value

Skip: The default step size is 1

Print: Whether this time output

3. Cycle Realization Rotation

Values: A list of value to rotate

4, Debug Open Debugging Window

5. Eval evaluates the value of the variable

Grammar:

{eval var= #ErrorState # assign= "State_error"}

Var: The variable name to be evaluated

Assign: Save the result, but this time does not output

6. Fetch reads the contents of the file and outputs

{Fetch file= "file" assign= "var"}

File: File name

Assign: Save results this time not output

7, Html_image in the page, print a picture

{html_image file= "pumpkin.jpg"}

File: Image Address

8. Html_table the array elements into a table (only for simple arrays)

{html_table loop= $data cols=4 table_attr= ' border= "0"}

Loop: The array to traverse must be added

Cols: How many cells are displayed per row default is three

Table_atr: Table Properties

9. Html_checkboxes print a set of check boxes

{html_checkboxes values= $cust _ids checked= $customer _id output= $cust _names separator= "
"}

Values: An array of value

Checked: An array of values for the selected item

Output: An array of text

Separator: delimiter separation between each complex option

Name: Name This set of checkboxes Note: Smarty will automatically add [], which means the array

Template code:

PHP Code:

http://www.bkjia.com/PHPjc/993262.html www.bkjia.com true http://www.bkjia.com/PHPjc/993262.html techarticle php-smarty-5 (phpsmarty-522), the previous article 11, Section,sectionelse section is a circular structure statement, mainly used to iterate over the array syntax: {section name= name loop= loop ...

  • Related Article

    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.