smarty模板是一种缓存技术,下面介绍一下smarty string_format用法 取小数点后2位:
用法如下:
//index.php
$smarty = new Smarty; $smarty->assign('number', 23.5787446); $smarty->display('index.tpl'); //index.tpl: {$number} {$number|string_format:"%.2f"} {$number|string_format:"%d"} //OUTPUT: //23.5787446 //23.58 //24