|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-07-15 09:52 UTC] delboy1978uk at gmail dot com
Description: ------------ When using numfmt_create() and numfmt_currency(), PHP flakes out and gives us some number in Scientific Notation, instead of formatting like US currency. Look here https://3v4l.org/QgS7U Test script: --------------- <?php $fmt = numfmt_create('en_US', NumberFormatter::TYPE_CURRENCY ); echo numfmt_format_currency($fmt, 32.00, "USD")."\n"; $fmt = new NumberFormatter( 'en_US', NumberFormatter::CURRENCY ); echo $fmt->formatCurrency(32.00, "USD")."\n"; /* output as follows 3.2E1 $32.00 Expected result: ---------------- $32.00 $32.00 Actual result: -------------- 3.2E1 $32.00 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 02:00:01 2025 UTC |
In addition to the bug description provided, I have the following example, using the procedural functions: $fmt = numfmt_create('en_US', NumberFormatter::DECIMAL); echo numfmt_format_currency($fmt, 32.00, "EUR")."\n"; I would expect that this would return 32,00, however, it returns 32. I've used a number of ISO 4217 currency codes (specifically USD, EUR, AUD, GBP) but the output remains the same. It's worth noting that if the float value provided to numfmt_format_currency contains a fractional part, in addition to the integral part, then the number formats as expected. Environment Details: PHP 7.3.6 / macOS 10.14.5.