DateTimeImmutable::getLastErrors
警告およびエラーを返す
&reftitle.description;
public static arrayfalseDateTimeImmutable::getLastErrors
日付/時刻文字列のパース時に見つかった警告やエラーの配列を返します。
&reftitle.parameters;
&no.function.parameters;
&reftitle.returnvalues;
警告やエラーに関する情報を含む配列を返します。
警告やエラーがない場合は &false; を返します。
&reftitle.changelog;
&Version;
&Description;
8.2.0
PHP 8.2.0 より前のバージョンでは、
この関数は警告やエラーがない場合でも &false; を返しませんでした。
代わりに、例に示している、警告やエラーに関する情報を含む配列を常に返していました。
&reftitle.examples;
DateTimeImmutable::getLastErrors の例
getMessage();
}
?>
]]>
&examples.outputs;
1
[warnings] => Array
(
[6] => Double timezone specification
)
[error_count] => 1
[errors] => Array
(
[0] => The timezone could not be found in the database
)
)
]]>
この出力のインデックス 6 と 0 は、エラーが発生した文字列内での文字の位置を表します。