0
点赞
收藏
分享

微信扫一扫

smarty下如何将一个数保存为两位小数


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


你要保守你心,胜过保守一切。

作者:刘俊涛的博客​​




举报

相关推荐

0 条评论