Smarty commonly used 20 variable operators * Use syntax: {variable name | operator:}
* Capitalize---First letter capital
* Count_characters---count characters
* Cat---connection string
* Count_paragraphs---Calculation of paragraphs
* Count_sentences---Calculation of the number of sentences
* Count_words---Number of words calculated
* Date_format---time format
* Default---Defaults
* Escape---transcoding
* Indent---Indent
* Lower---lowercase
* NL2BR---newline character replaced by
* Regex_replace---Replacement
* Replace---Replacement
* Spacify---interpolation
* String_format---string format
* Strip---remove extra space
* Strip_tags---Remove HTML tags
* Truncate---interception
* Upper---Caps
* WordWrap--Constraint line width
How to use:
index.php
Copy Code code as follows:
Include ("smarty_inc.php");
$name = "My name is Maji,age 22,sex boy.<a href=>aaaaaa</a>.";
$smarty->assign ("title", $name);
$smarty->assign ("Row", $row);
$smarty->assign ("D", Strtotime ("-0"));
$smarty->assign ("Nubmer", 342345.736524);
$smarty->display ("index.html");
?>
Index.html
Raw data: {$title}
After using the capitalize variable operator: {$title |capitalize}
After using the Count_characters variable operator: {$title |count_characters}
After using the cat variable operator: {$title |cat: "Wwww.baidu.com"}
After using the count_paragraphs variable operator: {$title |count_paragraphs}
After using the count_sentences variable function operator: {$title |count_sentences}
After using the Count_words variable function operation: {$title |count_words}
Raw time data: {$d}
Using the Date_format variable function operation: {$d |date_format: "%y-%m-%d"}
Use Smarty.now call time: {$smarty. Now|date_format: "%y-%m-%d"}
Use the default variable function action: {$title 1|default: "No This Variable"}
Operation with escape variable function: {$title |escape: "HTML"}
Using the Indent variable function operation: {$title |indent:2:}
Using the lower variable function operation: {$title |lower}
Using the upper variable function operation: {$title |upper}
Use the Replace variable function action: {$title |replace: "is": "@@"}
Using the spacify variable function operation: {$title |spacify: "_"}
Using the String_format variable function operation: {$nubmer |string_format: "%.2f"}
Use the Strip variable function action: {$title |strip: "_"}
Using the Strip_tags variable function operation: {$title |strip_tags}
Use TRUNCATE variable function action: {$title |truncate:30: "..."}
Using the WordWrap variable function operation: {$title |wordwrap:10: "<br>"}