Re: What to use?

From: Date: Thu, 25 Sep 2003 21:05:15 +0000
Subject: Re: What to use?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-164003@lists.php.net to get a copy of this message
*slaps self* Yep, forgot about that part of number format :) Rob. On Thu, 2003-09-25 at 16:51, CPT John W. Holmes wrote: > From: "Robert Cummings" <robert@interjinn.com> > > > On Thu, 2003-09-25 at 16:28, Jeff McKeon wrote: > > > Correct me if I'm wrong please, but I think number_format() has the > > > adverse effect of changing the value type from numeric to char and > > > therefore baring you from using it in mathematical equation later in the > > > script. > > > > > > Anyway that's what it seemed to do to me when I used it on results from > > > a MySQL query... > > > > That shouldn't happen. PHP is a typeless language and so type > > conversions are juggled on the fly. If you pass a numerical string to a > > mathematical operator, then the string will be converted to the > > appropriate value. > > If you get a result of "1,234.56" from number_format() and try to use that > as a numerical value (i.e. it's converted to an int or float), you'll end up > with the value being 1, though. Everything after the first non-numeric > character is lost. That's what he's talking about. > > ---John Holmes... > > -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------'

« previous php.general (#164003) next »