RE: [SMARTY] problem displaying float

From: Date: Fri, 17 Nov 2006 16:05:41 +0000
Subject: RE: [SMARTY] problem displaying float
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13576@lists.php.net to get a copy of this message
Hi, So what are you using to print the variable in the template? e.g. {$variable} Or {php}echo $variable{/php} Or what? And do you use any modifier for the variable, or do you just use the variable as assigned to? Guido -----Oorspronkelijk bericht----- Van: George Pitcher [mailto:george.pitcher@ingenta.com] Verzonden: vrijdag 17 november 2006 16:45 Aan: Smarty-General Onderwerp: RE: [SMARTY] problem displaying float > On Fri, Nov 17, 2006 at 02:10:12PM -0000, George Pitcher wrote: > [...] > > The actual code for this page is long and complex, but the > relevant snippet > > looks like: > > =========================================================== > > $fee = [web-service response (in dollars and cents)] > > settype($fee, "float"); > > $fee_type = gettype($fee); > > $range = explode(",",strim($pr)); > > $rangecounter = count($range); > > $rangecounter = ($rangecounter>1?$rangecounter-1:0); > > $ccc_supp = floatval($rangecounter * 3); > > settype($ccc_supp, "float"); > > $fee2 = $fee + $ccc_supp; > > > > $smarty->assign('ccc_fee',($rt!='Granted'?'Not available > > through CCC: > > '.($rt!=''?$rt:'no reason given'):'The CCC QuickPrice for > > this > request is: > > $'.sprintf("%01.2f",$fee2)."<br>$ccc_terms")); > > =========================================================== > > $pr is a pagerange and in the example is 9-27. extended range might be > > 1-3,9-27, which would then add $3 to the $fee variable. > > =========================================================== > > > > If I echo $fee, for my example, I get 160.44. If I echo $fee2, > I get 160.00. > > But all I've done is add '0' to the $fee variable. > > this is your third post on the topic and you still refused to show us a > single line of template code. > > now you show us a case where you trigger the error without any smarty > interference (I think we can ignore the $smarty->assign() and your > error occurs with or without it). > > so what has this to do with smarty anyway? > messju I do all my calculations in PHP and let Smarty handle the display - I thought that's what templates were all about. The problem I have is that my display via $smarty-assign() was giving me an incorrect display. I then, as usual with such an error, thought there was something wrong with the PHP code, so started echoing the output at the various steps. I still thought the problem was in PHP, but when I decided to put the process into a php file that did not include and $smarty interaction, the display was fine, which is why I'm asking the question on this list. If no-one has a solution, I'll need to think of a different way to display the price to my users. Cheers George -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.general (#13576) next »