RE: [SMARTY] problem displaying float
| From: | George Pitcher | Date: | Fri, 17 Nov 2006 13:11:51 +0000 |
| Subject: | RE: [SMARTY] problem displaying float | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-13570@lists.php.net to get a copy of this message | ||
> > The following code:
> >
> > $fee = 160.44;
> > $fee2 = $fee + 0; // I have a reason for adding zero;
> > echo $fee."<br>";
> > echo $fee2."<br>";
> > settype($fee, "float");
> > echo gettype($fee);
> >
>
> I'd be more interested to know what gettype shows before the settype,
> and also for gettype($fee2).
>
> > [...]
> > and
> >
> > 160.44
> > 160
> > NULL
> >
> > when echo'd on a page using a Smarty template.
> >
>
> What does your Smarty template look like? Where are you doing the
> "maths" (the +0 bit) - within the template?
>
> I'm really not clear what you're assigning to the template, or how
> you're showing it.
>
Mark,
gettype($fee) before settype() gave me 'object'.
I'm doing all this in the php and sending it to the template using echo.
Initially I was sending to the template with a $smarty->assign('variable',
sprintf("%01.2f",$fee2));
Hope trhat's a bit clearer.
George