NumberFormatter
class NumberFormatter (View source)
Constants
CURRENCY_ACCOUNTING |
|
PATTERN_DECIMAL |
Decimal format defined by pattern |
DECIMAL |
Decimal format |
CURRENCY |
Currency format |
PERCENT |
Percent format |
SCIENTIFIC |
Scientific format |
SPELLOUT |
Spellout rule-based format |
ORDINAL |
Ordinal rule-based format |
DURATION |
Duration rule-based format |
PATTERN_RULEBASED |
Rule-based format defined by pattern |
IGNORE |
Alias for PATTERN_DECIMAL |
DEFAULT_STYLE |
Default format for the locale |
ROUND_CEILING |
Rounding mode to round towards positive infinity. |
ROUND_FLOOR |
Rounding mode to round towards negative infinity. |
ROUND_DOWN |
Rounding mode to round towards zero. |
ROUND_UP |
Rounding mode to round away from zero. |
ROUND_HALFEVEN |
Rounding mode to round towards the "nearest neighbor" unless both
neighbors are equidistant, in which case, round towards the even
neighbor. |
ROUND_HALFDOWN |
Rounding mode to round towards "nearest neighbor" unless both neighbors
are equidistant, in which case round down. |
ROUND_HALFUP |
Rounding mode to round towards "nearest neighbor" unless both neighbors
are equidistant, in which case round up. |
PAD_BEFORE_PREFIX |
Pad characters inserted before the prefix. |
PAD_AFTER_PREFIX |
Pad characters inserted after the prefix. |
PAD_BEFORE_SUFFIX |
Pad characters inserted before the suffix. |
PAD_AFTER_SUFFIX |
Pad characters inserted after the suffix. |
PARSE_INT_ONLY |
Parse integers only. |
GROUPING_USED |
Use grouping separator. |
DECIMAL_ALWAYS_SHOWN |
Always show decimal point. |
MAX_INTEGER_DIGITS |
Maximum integer digits. |
MIN_INTEGER_DIGITS |
Minimum integer digits. |
INTEGER_DIGITS |
Integer digits. |
MAX_FRACTION_DIGITS |
Maximum fraction digits. |
MIN_FRACTION_DIGITS |
Minimum fraction digits. |
FRACTION_DIGITS |
Fraction digits. |
MULTIPLIER |
Multiplier. |
GROUPING_SIZE |
Grouping size. |
ROUNDING_MODE |
Rounding Mode. |
ROUNDING_INCREMENT |
Rounding increment. |
FORMAT_WIDTH |
The width to which the output of format() is padded. |
PADDING_POSITION |
The position at which padding will take place. See pad position
constants for possible argument values. |
SECONDARY_GROUPING_SIZE |
Secondary grouping size. |
SIGNIFICANT_DIGITS_USED |
Use significant digits. |
MIN_SIGNIFICANT_DIGITS |
Minimum significant digits. |
MAX_SIGNIFICANT_DIGITS |
Maximum significant digits. |
LENIENT_PARSE |
Lenient parse mode used by rule-based formats. |
POSITIVE_PREFIX |
Positive prefix. |
POSITIVE_SUFFIX |
Positive suffix. |
NEGATIVE_PREFIX |
Negative prefix. |
NEGATIVE_SUFFIX |
Negative suffix. |
PADDING_CHARACTER |
The character used to pad to the format width. |
CURRENCY_CODE |
The ISO currency code. |
DEFAULT_RULESET |
The default rule set. This is only available with rule-based
formatters. |
PUBLIC_RULESETS |
The public rule sets. This is only available with rule-based
formatters. This is a read-only attribute. The public rulesets are
returned as a single string, with each ruleset name delimited by ';'
(semicolon). |
DECIMAL_SEPARATOR_SYMBOL |
The decimal separator. |
GROUPING_SEPARATOR_SYMBOL |
The grouping separator. |
PATTERN_SEPARATOR_SYMBOL |
The pattern separator. |
PERCENT_SYMBOL |
The percent sign. |
ZERO_DIGIT_SYMBOL |
Zero. |
DIGIT_SYMBOL |
Character representing a digit in the pattern. |
MINUS_SIGN_SYMBOL |
The minus sign. |
PLUS_SIGN_SYMBOL |
The plus sign. |
CURRENCY_SYMBOL |
The currency symbol. |
INTL_CURRENCY_SYMBOL |
The international currency symbol. |
MONETARY_SEPARATOR_SYMBOL |
The monetary separator. |
EXPONENTIAL_SYMBOL |
The exponential symbol. |
PERMILL_SYMBOL |
Per mill symbol. |
PAD_ESCAPE_SYMBOL |
Escape padding character. |
INFINITY_SYMBOL |
Infinity symbol. |
NAN_SYMBOL |
Not-a-number symbol. |
SIGNIFICANT_DIGIT_SYMBOL |
Significant digit symbol. |
MONETARY_GROUPING_SEPARATOR_SYMBOL |
The monetary grouping separator. |
TYPE_DEFAULT |
Derive the type from variable type |
TYPE_INT32 |
Format/parse as 32-bit integer |
TYPE_INT64 |
Format/parse as 64-bit integer |
TYPE_DOUBLE |
Format/parse as floating point value |
deprecated TYPE_CURRENCY |
Format/parse as currency value |
ROUND_TOWARD_ZERO
Since: 8.4
|
|
ROUND_AWAY_FROM_ZERO
Since: 8.4
|
|
ROUND_HALFODD
Since: 8.4
|
|
Methods
No description
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Create a number formatter
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Format a number
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Parse a number
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Format a currency value
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Parse a currency number
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Set an attribute
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get an attribute
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Set a text attribute
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get a text attribute
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Set a symbol value
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get a symbol value
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Set formatter pattern
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get formatter pattern
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get formatter locale
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get formatter's last error code.
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get formatter's last error message.
Details
__construct(string $locale, int $style, string $pattern = null)
No description
static NumberFormatter|null
create(string $locale, int $style, string $pattern = null)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Create a number formatter
string|false
format(int|float $num, int $type = 0)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Format a number
int|float|false
parse(string $string, int $type = NumberFormatter::TYPE_DOUBLE, int $offset = null)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Parse a number
string|false
formatCurrency(float $amount, string $currency)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Format a currency value
float|false
parseCurrency(string $string, string $currency, int $offset = null)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Parse a currency number
bool
setAttribute(int $attribute, int $value)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Set an attribute
int|float|false
getAttribute(int $attribute)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get an attribute
bool
setTextAttribute(int $attribute, string $value)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Set a text attribute
string|false
getTextAttribute(int $attribute)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get a text attribute
bool
setSymbol(int $symbol, string $value)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Set a symbol value
string|false
getSymbol(int $symbol)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get a symbol value
bool
setPattern(string $pattern)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Set formatter pattern
string|false
getPattern()
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get formatter pattern
string|false
getLocale(int $type = 0)
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get formatter locale
int
getErrorCode()
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get formatter's last error code.
string
getErrorMessage()
(PHP 5 >= 5.3.0, PECL intl >= 1.0.0)
Get formatter's last error message.