php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10537 number_format ing variables breaks totals
Submitted: 2001-04-28 12:07 UTC Modified: 2001-04-28 12:16 UTC
From: mguertin at macdiscussion dot com Assigned:
Status: Not a bug Package: *Function Specific
PHP Version: 4.0.4pl1 OS: OS X, Linux, Solaris
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mguertin at macdiscussion dot com
New email:
PHP Version: OS:

 

 [2001-04-28 12:07 UTC] mguertin at macdiscussion dot com
I finally got some time to write some code to show this...I 
may be wrong in assuming the behaviour, but either way the 
totals are definately wrong.  Here's the snippet:

$value = 1234;

$total = $value + $value;
print number_format($value,2) . " + " . 
number_format($value,2) . " = " . number_format($total,2);

print "<BR><BR>";

$value = number_format($value,2);
$total = $value + $value;
print $value . " + " . $value . " = " . $total;



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-28 12:16 UTC] derick@php.net
This is not a bug, after the first number_format in the second piece, $value is a string.
When adding strings, the variabele gets converted back to a integer or float, but uonly until the first character that is not in the set [0-9] or .
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 16:01:31 2024 UTC