(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)
IntlDateFormatter::getErrorCode -- datefmt_get_error_code — 取得上次操作的錯誤碼
物件導向風格
程序式風格
返回上次格式化操作的錯誤碼。
formatter
格式器資源。
錯誤碼,為 UErrorCode 值之一。初始值為 U_ZERO_ERROR。
範例 #1 datefmt_get_error_code() 範例
<?php
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
$str = datefmt_format($fmt, 0);
printf(
"錯誤:%s (%d)\n",
datefmt_get_error_message($fmt),
datefmt_get_error_code($fmt)
);
?>
範例 #2 物件導向範例
<?php
$fmt = new IntlDateFormatter(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
$str = $fmt->format(0);
printf(
"錯誤:%s (%d)\n",
$fmt->getErrorMessage(),
$fmt->getErrorCode()
);
?>
以上範例將輸出
ERROR: U_ZERO_ERROR (0)