1.什麼是Smarty模板引擎中的變量操做符?
變量操做符實際上就是php模板引擎smarty內置的一些操做函數,咱們稱之爲變量操做符,變量操做符可用於操做變量,自定義函數和字符。語法中使用"|"應用變量操做符,多個參數用":" 分隔開來。
{
$
name
|
truncate
:10:"..."}
2.經常使用的變量操做符
capitalize
[
首字母大寫
]
count_characters
[
計算字符數
]
cat
[
鏈接字符串
]
count_paragraphs
[
計算段落數
]
count_sentences
[
計算句數
]
count_words
[
計算詞數
]
date_format
[
時間格式
]
default
[
默認
]
escape
[
轉碼
]
indent
[
縮進
]
lower
[
小寫
]
nl2br
[
換行符替換成
<br />]
regex_replace
[
正則替換
]
replace
[
替換
]
spacify
[
插空
]
string_format
[
字符串格式化
]
strip
[
去除
(
多餘空格
)]
strip_tags
[
去除
html
標籤
]
truncate
[
截取
]
upper
[
大寫
]
wordwrap
[
行寬約束
]