2024 年 PHP 日本研討會

IntlDateFormatter::getErrorCode

datefmt_get_error_code

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL intl >= 1.0.0)

IntlDateFormatter::getErrorCode -- datefmt_get_error_code取得上次操作的錯誤碼

說明

物件導向風格

public IntlDateFormatter::getErrorCode(): int

程序式風格

datefmt_get_error_code(IntlDateFormatter $formatter): int

返回上次格式化操作的錯誤碼。

參數

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)

參見

新增註釋

使用者貢獻的註釋

此頁面沒有使用者貢獻的註釋。
To Top