Smarty Common 20 variable operators * Use syntax: {variable name | operator:}
* Capitalize---initial capital letter
* Count_characters---Count of characters
* Cat---connection string
* Count_paragraphs---Calculation of the number of paragraphs
* Count_sentences---Calculation of sentences
* Count_words---Calculation of the number of words
* Date_format---time format
* Default---Defaults
* Escape---transcoding
* Indent---Indent
* Lower---lowercase
* NL2BR---newline character replaced by
* Regex_replace---regular replacement
* Replace---Replacement
* Spacify---intervening spaces
* String_format---string formatting
* Strip---remove extra spaces
* Strip_tags---Remove HTML tags
* Truncate---interception
* Upper---capital
* WordWrap--Constrain line width
How to use:
index.php
Copy CodeThe code is as follows:
Include ("smarty_inc.php");
$name = "My name is Maji,age 22,sex boy.aaaaaa.";
$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}
Use 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 operation: {$title 1|default: "Without this variable"}
Operation with escape variable function: {$title |escape: "HTML"}
Use the Indent variable function operation: {$title |indent:2: ""}
Use the lower variable function operation: {$title |lower}
Use the upper variable function operation: {$title |upper}
Use the Replace variable function operation: {$title |replace: "is": "@@"}
Use the spacify variable function operation: {$title |spacify: "_"}
Use the String_format variable function operation: {$nubmer |string_format: "%.2f"}
Use the Strip variable function operation: {$title |strip: "_"}
Use the Strip_tags variable function operation: {$title |strip_tags}
Use the TRUNCATE variable function operation: {$title |truncate:30: "..."}
Use the WordWrap variable function operation: {$title |wordwrap:10: "
"}
http://www.bkjia.com/PHPjc/320939.html www.bkjia.com true http://www.bkjia.com/PHPjc/320939.html techarticle smarty commonly used 20 variable operators * Use syntax: {variable name | operator:} * Capitalize---Initial capital letter * Count_characters---count characters * Cat---connection string * Coun ...