라이브러리
[PHP_CONFIG] intl.use_exceptions - Intl 확장에서 예외 사용 여부
PHP CONFIG 에서 intl.use_exceptions는 국제화(Internationalization, I18N) 관련 설정입니다.
intl.use_exceptions
intl.use_exceptions는 국제화 관련 예외를 처리하는 설정입니다. 기본적으로 이 설정은 FALSE로 설정되어 있습니다.
# TRUE
intl.use_exceptions를 TRUE로 설정하면, 국제화 관련 예외가 발생할 때 PHP가 예외를 throw합니다.
#hostingforum.kr
php
intl.use_exceptions = TRUE
# FALSE
intl.use_exceptions를 FALSE로 설정하면, 국제화 관련 예외가 발생할 때 PHP는 예외를 catch하지 않고, 오류 메시지를 출력합니다.
#hostingforum.kr
php
intl.use_exceptions = FALSE
예제
intl.use_exceptions를 TRUE로 설정한 예제입니다.
#hostingforum.kr
php
intl.use_exceptions = TRUE
try {
$locale = new Locale('ko_KR');
$locale->setDefaultCategory(Locale::LC_ALL);
} catch (Exception $e) {
echo $e->getMessage();
}
intl.use_exceptions를 FALSE로 설정한 예제입니다.
#hostingforum.kr
php
intl.use_exceptions = FALSE
$locale = new Locale('ko_KR');
$locale->setDefaultCategory(Locale::LC_ALL);
결과
intl.use_exceptions를 TRUE로 설정한 경우, 국제화 관련 예외가 발생할 때 PHP는 예외를 throw하고, catch 블록에서 예외를 처리합니다.
intl.use_exceptions를 FALSE로 설정한 경우, 국제화 관련 예외가 발생할 때 PHP는 예외를 catch하지 않고, 오류 메시지를 출력합니다.
참고
intl.use_exceptions는 PHP 5.5.0 이상에서 사용할 수 있습니다.
intl.use_exceptions를 TRUE로 설정할 때, catch 블록에서 예외를 처리할 수 있습니다.
intl.use_exceptions를 FALSE로 설정할 때, catch 블록은 필요하지 않습니다.
결론
intl.use_exceptions는 국제화 관련 예외를 처리하는 설정입니다. TRUE로 설정하면 예외를 throw하고, FALSE로 설정하면 오류 메시지를 출력합니다.
intl.use_exceptions를 사용할 때, catch 블록을 사용하여 예외를 처리할 수 있습니다.
추천
intl.use_exceptions를 TRUE로 설정하는 것을 추천합니다. 예외를 throw하여 catch 블록에서 예외를 처리하는 것이 더 안전하고, 유지보수하기 쉬운 코드를 작성할 수 있습니다.
예제 코드
intl.use_exceptions를 TRUE로 설정한 예제 코드입니다.
#hostingforum.kr
php
intl.use_exceptions = TRUE
try {
$locale = new Locale('ko_KR');
$locale->setDefaultCategory(Locale::LC_ALL);
} catch (Exception $e) {
echo $e->getMessage();
}
intl.use_exceptions를 FALSE로 설정한 예제 코드입니다.
#hostingforum.kr
php
intl.use_exceptions = FALSE
$locale = new Locale('ko_KR');
$locale->setDefaultCategory(Locale::LC_ALL);
댓글목록
등록된 댓글이 없습니다.