Php-Smarty-3 (20)

Source: Internet
Author: User
Tags html comment
: This article mainly introduces the php-Smarty-3 (20), for PHP tutorials interested in students can refer to it. I. Notes

* Comment *

Html comment shows the client source file

The Smarty annotation is not sent to the client.

The note of Smarty is mainly for template designers.

II. variables in the template

L allocated by the php file

1) common variables

2) array variables

3) object variables

Program code:

Template code:

1. allocated by the configuration file

Configuration File:

Template code:

2. create in the template file

III. variable regulator

The variable regulator is mainly used to format variables.

Syntax:

{$ Var | regulator: parameter 1: parameter 2 :......}

L {$ var | capitalize}: uppercase letters

L {$ var | count_characters: true}: calculates the string length. true: calculates the space. default value: false.

L {$ var | cat: var2}: connection string

L {$ var | count_paragraphs}: calculates the number of paragraphs.

L {$ var | count_sentences}: calculates the number of periods.

L {$ var | count_words}: calculates the number of words.

L {$ var | date_format: "% H % M % S"}: formatting time

L {$ var | default: "value"}: default value

L {$ var | escape}: Transcoding

L {$ var | indent: 10: "*"}: indent

L {$ var | lower}: lower case

L {$ var | nl2br}: convert the file line break to a Web page line break.

L {$ var | regex_replace: "/[\ t \ n]/": ""}: Regular expression replacement

L {$ var | replace: "aa": "bb"}: string replacement

L {$ var | spacify: "^"}: Blank

L {$ var | string_format: "% d"}: string formatting

L {$ var | strip}: removes consecutive spaces.

L {$ var | strip_tags}: removes html tags.

L {$ var | truncate: 30 :"..."} : End string

L {$ var | upper}: Converts to uppercase

L {$ var | wordwrap: 30: "\ n"}: row width constraint

Variable regulator combination

{$ Var | capitalize | truncate: 30 :"..." | Replace: "aa": "bb "}

1) capital the first letter of the $ var variable

2) then extract 30 strings from $ var.

3) Replace aa in the intercepted content with bb.

The above introduces the php-Smarty-3 (20), including the content of the aspect, hope to be interested in PHP Tutorial friends help.

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.