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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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 Mar 28 09:01:26 2024 UTC