RE: [PHP] PHP 4.2.2 Float->Mysql addition problem
| From: | Ford, Mike | Date: | Fri, 03 Feb 2006 14:13:43 +0000 |
| Subject: | RE: [PHP] PHP 4.2.2 Float->Mysql addition problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-229806@lists.php.net to get a copy of this message | ||
On 03 February 2006 13:14, Andrei wrote:
> Welcome,
> Please note that using bc function variables will be of type string.
> So a code working with numeric values like:
>
> $a = 1;
> if( $a )
> {
> ...
> }
>
> it's ok but with bc functions:
>
> $a = 14.5;
> $b = -14.5;
> $c = bcadd( $a, $b );
> if( $c )
> {
> ...
> }
>
> will not work as expected ( if( "0" ) is interpreted like a string
> that is not null and so condition is interpreted as true.
Er - nope. The string "0" is explicitly equivalent to FALSE -- see http://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm