|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-02-05 20:16 UTC] msaraujo@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 01:00:01 2025 UTC |
Description: ------------ An interesting bug, if you do the following: $val = 2345.35; $val = sprintf("%01.2f", $val); echo $val; Output is "2.00", instead of "2345.35". The solution is to use an intermediate variable: $val = 2345.35; $val2 = sprintf("%01.2f", $val); $val = $val2; echo $val; Reproduce code: --------------- $val = 2345.35; $val = sprintf("%01.2f", $val); echo $val; Expected result: ---------------- 2345.35 Actual result: -------------- 2.00