1
0
mirror of https://github.com/php/doc-es.git synced 2026-03-24 07:22:16 +01:00
Files
2025-11-03 11:50:15 +01:00

156 lines
3.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 3a8c3e77df070a046c9d5b56b68926ca2d7e5ee3 Maintainer: Marqitos Status: ready -->
<!-- Reviewed: no -->
<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>Devuelve las advertencias y errores</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>
Devuelve un array de advertencias y errores encontrados mientras se analizaba
una cadena de fecha/hora.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Devuelve un array que contiene información sobre advertencias y errores, o &false; si no
hay ni advertencias ni errores.
</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>
Antes de PHP 8.2.0, esta función no devolvía &false;
cuando no había advertencias ni errores. En su lugar, siempre
devolvía la estructura de array documentada.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>DateTimeImmutable::getLastErrors</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
try {
$date = new DateTimeImmutable('asdfasdf');
} catch (Exception $e) {
// Solo para fines de demostración...
print_r(DateTimeImmutable::getLastErrors());
// La forma correcta de hacer esto con programación orientada a objetos es
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>
Los índices 6, y 0 en la salida de ejemplo se refieren al índice de caracteres en la cadena donde ocurrió el error.
</para>
</example>
<example>
<title>Detectando fechas desbordadas</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
-->