Php-smarty-3 (phpsmarty-320_php), tutorial

Source: Internet
Author: User

Php-smarty-3 (), phpsmarty-320


First, comments

* Note content *

HTML comments are displayed in the client source file

Smarty comments are not sent to the client

Smarty's comments are mainly for the template designer to see

Second, the variables in the template

L is assigned by PHP file

1) Common variables

2) Array variables

3) Object variables

Program code:

Template code:

1 Allocation by configuration file

Configuration file:

Template code:

2 Create in template file

Three, variable regulator

The variable adjuster is mainly the format of the variable.

Grammar:

{$var | regulator: Parameter 1: Parameter 2: ...}

L {$var |capitalize}: Capitalize first letter

L {$var |count_characters:true}: Calculate string length true: Calculate space default: False

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

L {$var |count_paragraphs}: Count of paragraphs

L {$var |count_sentences}: Count of sentences

L {$var |count_words}: Count of words

L {$var |date_format: "%h%m%s"}: Format time

L {$var |default: "Value"}: Default Value

L {$var |escape}: transcoding

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

L {$var |lower}: Lowercase

L {$var |NL2BR}: Convert file line breaks to Web page breaks

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

L {$var |replace: "AA": "BB"}: String substitution

L {$var |spacify: "^^"}: Intervening spaces

L {$var |string_format: '%d '}: String formatting

L {$var |strip}: Remove contiguous spaces

L {$var |strip_tags}: Removing HTML tags

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

L {$var |upper}: Convert to Uppercase

L {$var |wordwrap:30: ' \ n '}: Row width constraint

Combination of variable Conditioners

{$var |capitalize|truncate:30: "..." |replace: "AA": "BB"}

1) Capitalize the $var variable first letter

2) then intercept 30 strings from the $var

3) Replace AA in the intercepted content with BB

http://www.bkjia.com/PHPjc/993265.html www.bkjia.com true http://www.bkjia.com/PHPjc/993265.html techarticle php-smarty-3 (phpsmarty-320), comments * Comments * Comment Content * HTML comments Display client source files Smarty comments will not be sent to the client Smarty comments mainly to the template designer to ...

  • 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.