Internationalization NumberFormatter::setAttribute
NumberFormatter::setAttribute
numfmt_set_attribute
(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
NumberFormatter::setAttribute -- numfmt_set_attribute — 속성 설정
설명
객체 지향 스타일 (method)
public NumberFormatter::setAttribute(int $attribute
, int|float $value
): bool
절차적 스타일
numfmt_set_attribute(NumberFormatter $formatter
, int $attribute
, int|float $value
): bool
포맷터와 연결된 숫자 속성을 설정합니다. 숫자 속성의 예는 포맷터가 생성할 정수 자릿수입니다.
매개변수
formatter
- NumberFormatter object.
attribute
- 속성 지정자 - 숫자 속성 상수 중 하나입니다.
value
- 속성 값입니다.
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
Examples
예제 #1 numfmt_set_attribute() 예제
<?php
$fmt = numfmt_create( 'de_DE', NumberFormatter::DECIMAL );
echo "Digits: ".numfmt_get_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
numfmt_set_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS, 2);
echo "Digits: ".numfmt_get_attribute($fmt, NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo numfmt_format($fmt, 1234567.891234567890000)."\n";
?>
예제 #2 OO 예제
<?php
$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
echo "Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo $fmt->format(1234567.891234567890000)."\n";
$fmt->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 2);
echo "Digits: ".$fmt->getAttribute(NumberFormatter::MAX_FRACTION_DIGITS)."\n";
echo $fmt->format(1234567.891234567890000)."\n";
?>
위의 예는 다음을 출력합니다.
Digits: 3 1.234.567,891 Digits: 2 1.234.567,89
기타
- numfmt_get_error_code() - 포맷터의 마지막 오류 코드 가져오기
- numfmt_get_attribute() - 속성 가져오기
- numfmt_set_text_attribute() - 텍스트 속성 설정