Technical stuff Requirements are like water. They're easier to build on when they're frozen.

Smarty: adding two numbers

11.27.2008 · Posted in Quick and dirty

Let’s start with the initialization:

{assign var="iItemOne" value=1}
{assign var="iItemTwo" value=2}

Beware that the first code is working, while the second is not:

{* Working sample *}

{assign var="iSum" value=$iItemOne+$iItemTwo}
Result of adding {$iItemOne} and {$iItemTwo} is {$iSum}.
{* Not working sample *}

{assign var="iSum" value=$iItemOne + $iItemTwo}
Result of adding {$iItemOne} and {$iItemTwo} is {$iSum}.
Tags:

2 Responses to “Smarty: adding two numbers”

  1. very useful information. thanks! :)

  2. In the case floating number?

    a=10.00
    b=10.00
    a+b getting 20 , not 20.00 ?

Leave a Reply