since version 2.3, to be removed in 3.0. Use {@link \Symfony\Component\Intl\NumberFormatter\NumberFormatter} instead.
__construct(string $locale = 'en', int $style = null, string $pattern = null)
Constructor.
Parameters
string | $locale | The locale code. The only currently supported locale is "en" (or null using the default locale, i.e. "en"). |
int | $style | Style of the formatting, one of the format style constants. The only supported styles are NumberFormatter::DECIMAL and NumberFormatter::CURRENCY. |
string | $pattern | Not supported. A pattern string in case $style is NumberFormat::PATTERNDECIMAL or NumberFormat::PATTERNRULEBASED. It must conform to the syntax described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation |
Exceptions
See also
http://www.php.net/manual/en/numberformatter.create.php | |
http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details | |
http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#_details | |
static NumberFormatter
create(string $locale = 'en', int $style = null, string $pattern = null)
Static constructor.
Parameters
string | $locale | The locale code. The only supported locale is "en" (or null using the default locale, i.e. "en"). |
int | $style | Style of the formatting, one of the format style constants. The only currently supported styles are NumberFormatter::DECIMAL and NumberFormatter::CURRENCY. |
string | $pattern | Not supported. A pattern string in case $style is NumberFormat::PATTERNDECIMAL or NumberFormat::PATTERNRULEBASED. It must conform to the syntax described in the ICU DecimalFormat or ICU RuleBasedNumberFormat documentation |
Return Value
Exceptions
See also
http://www.php.net/manual/en/numberformatter.create.php | |
http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details | |
http://www.icu-project.org/apiref/icu4c/classRuleBasedNumberFormat.html#_details | |
Format a currency value.
Parameters
float | $value | The numeric currency value |
string | $currency | The 3-letter ISO 4217 currency code indicating the currency to use |
Return Value
string | The formatted currency value |
See also
http://www.php.net/manual/en/numberformatter.formatcurrency.php | |
http://www.iso.org/iso/support/faqs/faqs_widely_used_standards/widely_used_standards_other/currency_codes/currency_codes_list-1.htm | |
Format a number.
Parameters
number | $value | The value to format |
int | $type | Type of the formatting, one of the format type constants. Only type NumberFormatter::TYPE_DEFAULT is currently supported. |
Return Value
bool|string | The formatted value or false on error |
Exceptions
See also
http://www.php.net/manual/en/numberformatter.format.php | |
bool|int
getAttribute(int $attr)
Returns an attribute value.
Parameters
int | $attr | An attribute specifier, one of the numeric attribute constants |
Return Value
bool|int | The attribute value on success or false on error |
See also
http://www.php.net/manual/en/numberformatter.getattribute.php | |
int
getErrorCode()
Returns formatter's last error code. Always returns the UZEROERROR class constant value.
Return Value
int | The error code from last formatter call |
See also
http://www.php.net/manual/en/numberformatter.geterrorcode.php | |
string
getErrorMessage()
Returns formatter's last error message. Always returns the UZEROERROR_MESSAGE class constant value.
Return Value
string | The error message from last formatter call |
See also
http://www.php.net/manual/en/numberformatter.geterrormessage.php | |
string
getLocale(int $type = Locale::ACTUAL_LOCALE)
Returns the formatter's locale.
The parameter $type is currently ignored.
Parameters
int | $type | Not supported. The locale name type to return (Locale::VALIDLOCALE or Locale::ACTUALLOCALE) |
Return Value
string | The locale used to create the formatter. Currently always returns "en". |
See also
http://www.php.net/manual/en/numberformatter.getlocale.php | |
bool|string
getPattern()
Not supported. Returns the formatter's pattern.
Return Value
bool|string | The pattern string used by the formatter or false on error |
Exceptions
See also
http://www.php.net/manual/en/numberformatter.getpattern.php | |
bool|string
getSymbol(int $attr)
Not supported. Returns a formatter symbol value.
Parameters
int | $attr | A symbol specifier, one of the format symbol constants |
Return Value
bool|string | The symbol value or false on error |
See also
http://www.php.net/manual/en/numberformatter.getsymbol.php | |
bool|string
getTextAttribute(int $attr)
Not supported. Returns a formatter text attribute value.
Parameters
int | $attr | An attribute specifier, one of the text attribute constants |
Return Value
bool|string | The attribute value or false on error |
See also
http://www.php.net/manual/en/numberformatter.gettextattribute.php | |
bool|string
parseCurrency(string $value, string $currency, int $position = null)
Not supported. Parse a currency number.
Parameters
string | $value | The value to parse |
string | $currency | Parameter to receive the currency name (reference) |
int | $position | Offset to begin the parsing on return this value will hold the offset at which the parsing ended |
Return Value
bool|string | The parsed numeric value of false on error |
Exceptions
See also
http://www.php.net/manual/en/numberformatter.parsecurrency.php | |
bool|string
parse(string $value, int $type = self::TYPE_DOUBLE, int $position)
Parse a number.
Parameters
string | $value | The value to parse |
int | $type | Type of the formatting, one of the format type constants. NumberFormatter::TYPE_DOUBLE by default |
int | $position | Offset to begin the parsing on return this value will hold the offset at which the parsing ended |
Return Value
bool|string | The parsed value of false on error |
See also
http://www.php.net/manual/en/numberformatter.parse.php | |
bool
setAttribute(int $attr, int $value)
Set an attribute.
Parameters
int | $attr | An attribute specifier, one of the numeric attribute constants. The only currently supported attributes are NumberFormatter::FRACTIONDIGITS, NumberFormatter::GROUPINGUSED and NumberFormatter::ROUNDING_MODE. |
int | $value | The attribute value. |
Return Value
bool | true on success or false on failure |
Exceptions
See also
http://www.php.net/manual/en/numberformatter.setattribute.php | |
bool
setPattern(string $pattern)
Not supported. Set the formatter's pattern.
Parameters
string | $pattern | A pattern string in conformance with the ICU DecimalFormat documentation |
Return Value
bool | true on success or false on failure |
Exceptions
See also
http://www.php.net/manual/en/numberformatter.setpattern.php | |
http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details | |
bool
setSymbol(int $attr, string $value)
Not supported. Set the formatter's symbol.
Parameters
int | $attr | A symbol specifier, one of the format symbol constants |
string | $value | The value for the symbol |
Return Value
bool | true on success or false on failure |
Exceptions
See also
http://www.php.net/manual/en/numberformatter.setsymbol.php | |
bool
setTextAttribute(int $attr, int $value)
Not supported. Set a text attribute.
Parameters
int | $attr | An attribute specifier, one of the text attribute constants |
int | $value | The attribute value |
Return Value
bool | true on success or false on failure |
Exceptions
See also
http://www.php.net/manual/en/numberformatter.settextattribute.php | |