note 127359 added to class.numberformatter
| From: | gwyneth dot llewelyn at gwynethllewelyn dot net | Date: | Fri, 29 Jul 2022 00:49:43 +0000 |
| Subject: | note 127359 added to class.numberformatter | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-219074@lists.php.net to get a copy of this message | ||
When using the
NumberFormatter class for pretty-printing currency in PHP 7.3 and 8+,
it's not clear from the documentation that you can use the empty string "" as the
locale for the constructor, and that will retrieve the default locale (whatever it has been set to
in your environment).
formatCurrency(), by contrast, does not accept the empty string for the default
currency symbol; it will display a 'generic' currency symbol instead (¤).
Tested with PHP 7.4.30, 8.0.21, 8.1.8 under Ubuntu Linux and 8.1.8 under macOS Big Sur (11.6.8). I
tried under other alternatives (e.g. Linux running on ARM chips, PHP 7.3.3) but sadly the
NumberFormatter library does not seem to be present (or could not be found) on those
systems...
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.157.133 (proxied: 2001:8a0:7116:7200:ac69:15f7:c5e9:63fe)
----
Manual Page -- https://php.net/manual/en/class.numberformatter.php
Edit -- https://main.php.net/note/edit/127359
Del: integrated -- https://main.php.net/note/delete/127359/integrated
Del: useless -- https://main.php.net/note/delete/127359/useless
Del: bad code -- https://main.php.net/note/delete/127359/bad+code
Del: spam -- https://main.php.net/note/delete/127359/spam
Del: non-english -- https://main.php.net/note/delete/127359/non-english
Del: in docs -- https://main.php.net/note/delete/127359/in+docs
Del: other reasons-- https://main.php.net/note/delete/127359
Reject -- https://main.php.net/note/reject/127359
Search -- https://main.php.net/manage/user-notes.php