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