在查看項目代碼時,發現smart代碼中有這樣寫。url
{if $auctionInfo.printingNum} 印數:{math equation="cid/1000" cid=$auctionInfo.printingNum format="%d"}千冊<br /> {/if}
意思是:把$auctionInfo.printingNum 的值賦值給cid,cid/1000,後面format是格式,數值型,若是要保留一位 format = "%.1f" ,保留兩位 format = "%.2f"spa
如下是官網給舉例子:.net
Example 8.24. {math}code
Example a:orm
{* $height=4, $width=5 *} {math equation="x + y" x=$height y=$width}
The above example will output:blog
9
Example b:ci
{* $row_height = 10, $row_width = 20, #col_div# = 2, assigned in template *} {math equation="height * width / division" height=$row_height width=$row_width division=#col_div#}
The above example will output:get
100
Example c:it
{* you can use parenthesis *} {math equation="(( x + y ) / z )" x=2 y=10 z=2}
The above example will output:io
6
Example d:
{* you can supply a format parameter in sprintf format *} {math equation="x + y" x=4.4444 y=5.0000 format="%.2f"}
The above example will output:
9.44 url:http://www.smarty.net/docsv2/en/language.function.math.tpl