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
Php-smarty-3 (20)