RE: [SMARTY] problem displaying float

"George Pitcher" <[email protected]> Fri, 17 Nov 2006 13:11:51 -0000
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
> > 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

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php