mirror of
https://github.com/php/doc-ja.git
synced 2026-03-24 15:12:22 +01:00
155 lines
3.9 KiB
XML
155 lines
3.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 3a8c3e77df070a046c9d5b56b68926ca2d7e5ee3 Maintainer: takagi Status: ready -->
|
|
|
|
<refentry xml:id="datetimeimmutable.getlasterrors" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>DateTimeImmutable::getLastErrors</refname>
|
|
<refpurpose>警告およびエラーを返す</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis role="DateTimeImmutable">
|
|
<modifier>public</modifier> <modifier>static</modifier> <type class="union"><type>array</type><type>false</type></type><methodname>DateTimeImmutable::getLastErrors</methodname>
|
|
<void/>
|
|
</methodsynopsis>
|
|
<para>
|
|
日付/時刻文字列のパース時に見つかった警告やエラーの配列を返します。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
&no.function.parameters;
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
警告やエラーに関する情報を含む配列を返します。
|
|
警告やエラーがない場合は &false; を返します。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.2.0</entry>
|
|
<entry>
|
|
PHP 8.2.0 より前のバージョンでは、
|
|
この関数は警告やエラーがない場合でも &false; を返しませんでした。
|
|
代わりに、例に示している、警告やエラーに関する情報を含む配列を常に返していました。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<example>
|
|
<title><function>DateTimeImmutable::getLastErrors</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
try {
|
|
$date = new DateTimeImmutable('asdfasdf');
|
|
} catch (Exception $e) {
|
|
// 使用例を出したかっただけ...
|
|
print_r(DateTimeImmutable::getLastErrors());
|
|
|
|
// オブジェクト指向流にやるなら、本来は以下のように書くべき
|
|
echo $e->getMessage();
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[warning_count] => 1
|
|
[warnings] => Array
|
|
(
|
|
[6] => Double timezone specification
|
|
)
|
|
|
|
[error_count] => 1
|
|
[errors] => Array
|
|
(
|
|
[0] => The timezone could not be found in the database
|
|
)
|
|
)
|
|
Failed to parse time string (asdfasdf) at position 0 (a): The timezone could not be found in the database
|
|
]]>
|
|
</screen>
|
|
<para>
|
|
この出力のインデックス 6 と 0 は、エラーが発生した文字列内での文字の位置を表します。
|
|
</para>
|
|
</example>
|
|
<example>
|
|
<title>繰り上がった日付を検知する</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$date = DateTimeImmutable::createFromFormat('!Y-m-d', '2020-02-30');
|
|
print_r(DateTimeImmutable::getLastErrors());
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[warning_count] => 1
|
|
[warnings] => Array
|
|
(
|
|
[10] => The parsed date was invalid
|
|
)
|
|
|
|
[error_count] => 0
|
|
[errors] => Array
|
|
(
|
|
)
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|