
在查看项目代码时,发现smart代码中有这样写。
{if $auctionInfo.printingNum}
印数:{math equation="cid/1000" cid=$auctionInfo.printingNum format="%d"}千册<br />
{/if}
意思是:把$auctionInfo.printingNum 的值赋值给cid,cid/1000,后面format是格式,数值型,如果要保留一位 format = "%.1f" ,保留两位 format = "%.2f"
以下是官网给举例子:
Example 8.24. {math}
Example a:
{* $height=, $width= *} {math equation="x + y" x=$height y=$width}
The above example will output:
9
Example b:
{* $row_height = , $row_width = , #col_div# = , assigned in template *} {math equation="height * width / division"
height=$row_height
width=$row_width
division=#col_div#}
The above example will output:
100
Example c:
{* you can use parenthesis *} {math equation="(( x + y ) / z )" x= y= z=}
The above example will output:
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