php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78068 Intl extension getTextAttribute incorrect result
Submitted: 2019-05-26 10:47 UTC Modified: 2019-05-26 17:05 UTC
From: shariefjamiel at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: intl (PECL)
PHP Version: 7.2.18 OS: ubuntu 18.04 - php 7.2.15
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: shariefjamiel at gmail dot com
New email:
PHP Version: OS:

 

 [2019-05-26 10:47 UTC] shariefjamiel at gmail dot com
Description:
------------
I am trying to use the Number formatter to get information but the get text attribute is returning strange results.

Test script:
---------------
setlocale(LC_ALL,'en_GB');
Locale::setDefault('en_GB');
$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);

// This should be currency symbol but result is null
$result = $formatter->getTextAttribute(NumberFormatter::CURRENCY_SYMBOL);

// This should be decimal sperator, but its the currency symbol
$result = $formatter->getTextAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL)

Expected result:
----------------
// This should be currency symbol but result is null
echo $formatter->getTextAttribute(NumberFormatter::CURRENCY_SYMBOL); // £

// This should be decimal sperator, but its the currency symbol
echo $formatter->getTextAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); // .

Actual result:
--------------
// This should be currency symbol but result is null
echo $formatter->getTextAttribute(NumberFormatter::CURRENCY_SYMBOL); // NULL

// This should be decimal sperator, but its the currency symbol
echo $formatter->getTextAttribute(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); // £

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-05-26 12:00 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Package: Date/time related +Package: intl -Assigned To: +Assigned To: cmb
 [2019-05-26 12:00 UTC] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

What you are actually looking for is NumberFormatter::getSymbol(),
see <https://3v4l.org/ZIU9I>.
 [2019-05-26 17:05 UTC] shariefjamiel at gmail dot com
Sorry my bad. You can close this.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Mar 13 21:01:32 2025 UTC