最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php smarty模版引擎中變量操作符及使用方法

 更新時(shí)間:2009年12月11日 16:53:17   作者:  
php smarty模版引擎中常用的20個(gè)變量操作符及使用方法
smarty常用的20個(gè)變量操作符 * 使用語(yǔ)法:{變量名|操作符:}
* capitalize ---首字母大寫
* count_characters ---計(jì)算字符數(shù)
* cat ---連接字符串
* count_paragraphs ---計(jì)算段落數(shù)
* count_sentences ---計(jì)算句數(shù)
* count_words ---計(jì)算詞數(shù)
* date_format ---時(shí)間格式
* default ---默認(rèn)
* escape ---轉(zhuǎn)碼
* indent ---縮進(jìn)
* lower ---小寫
* nl2br ---換行符替換為
* regex_replace ---正則替換
* replace ---替換
* spacify ---插空
* string_format ---字符串格式化
* strip ---去除多余空格
* strip_tags ---去除html標(biāo)簽
* truncate ---截取
* upper ---大寫
* wordwrap --約束行寬

使用方法:
index.php
復(fù)制代碼 代碼如下:

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
原始數(shù)據(jù):{$title}

使用capitalize變量操作符后:{$title|capitalize}
使用count_characters變量操作符后:{$title|count_characters}
使用cat變量操作符后:{$title|cat:"wwww.baidu.com"}
使用count_paragraphs變量操作符后:{$title|count_paragraphs}
使用count_sentences變量函數(shù)操作符后:{$title|count_sentences}
使用count_words變量函數(shù)操作后:{$title|count_words}
原始時(shí)間數(shù)據(jù):{$d}
使用date_format變量函數(shù)操作:{$d|date_format:"%Y-%m-%d"}
使用smarty.now調(diào)用時(shí)間:{$smarty.now|date_format:"%Y-%m-%d"}
使用default變量函數(shù)操作:{$title1|default:"沒(méi)有這個(gè)變量"}
使用escape變量函數(shù)操作:{$title|escape:"html"}
使用indent變量函數(shù)操作:{$title|indent:2:" "}
使用lower變量函數(shù)操作: {$title|lower}
使用upper變量函數(shù)操作:{$title|upper}
使用replace變量函數(shù)操作:{$title|replace:"is":"@@"}
使用spacify變量函數(shù)操作:{$title|spacify:"_"}
使用string_format變量函數(shù)操作:{$nubmer|string_format:"%.2f"}
使用strip變量函數(shù)操作:{$title|strip:"_"}
使用strip_tags變量函數(shù)操作:{$title|strip_tags}
使用truncate變量函數(shù)操作:{$title|truncate:30:"..."}
使用wordwrap變量函數(shù)操作:{$title|wordwrap:10:"<br>"}

相關(guān)文章

最新評(píng)論

鹤庆县| 射阳县| 丽水市| 海伦市| 荣昌县| 山西省| 于都县| 阳西县| 双鸭山市| 陵川县| 西贡区| 盐山县| 灵石县| 长子县| 永善县| 叙永县| 平舆县| 长寿区| 绥棱县| 汽车| 丘北县| 普洱| 大英县| 巴中市| 屏东市| 张掖市| 威海市| 日土县| 建瓯市| 定西市| 南皮县| 辽中县| 富裕县| 南通市| 娄底市| 乐都县| 启东市| 昌图县| 巴彦淖尔市| 临朐县| 泊头市|