|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80611 NumberFormatter appears to have broken in PHP 8.x.
Submitted: 2021-01-09 21:49 UTC Modified: 2021-01-11 18:44 UTC
From: kit dot soul at usweek dot net Assigned:
Status: Open Package: Output Control
PHP Version: 8.0.1 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
40 + 9 = ?
Subscribe to this entry?

 [2021-01-09 21:49 UTC] kit dot soul at usweek dot net
NumberFormatter's formatCurrency() function no longer respects an empty currency symbol.

Output of test script in PHP 7.4.13 (Windows):

	string(6) "0.0043"

Output of test script in PHP 8.0.1 (Windows):

	string(11) "BTC 0.0043"

Conclusion: Something has changed.

I cannot find any mention whatsoever of PHP 8 here:

I asked it here but nobody can even reproduce it (possibly because they don't use Windows?):

Test script:
$a = new \NumberFormatter('en_US', \NumberFormatter::CURRENCY);
$a->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, 8);
$a->setSymbol(NumberFormatter::CURRENCY_SYMBOL, ''); // It's empty because I want it "minimal" for a table cell.
var_dump($a->formatCurrency(0.0043, 'BTC'));


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-01-11 18:44 UTC]
That is apparently an upstream issue; when building PHP 8.0 with
ICU 66.1 everything works as expected, but with ICU 67.1 the issue
is reproducible.  It is not particularly related to BTC (that
currency is only supported as of ICU 68.1), but also reproduces
with EUR, for instance.  It is also not related to an empty string
as currency symbol, but shows with '$' as well.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Apr 13 20:01:23 2021 UTC