PHP date_get_last_errors() 函数

2025 年 1 月 6 日 | 阅读 1 分钟

如果在解析日期字符串时出现任何错误,此函数将在输出中显示警告/错误。

语法

示例 1

输出

Array
(
    [warning_count] => 1
    [warnings] => Array
        (
            [4] => Double timezone specification
        )

    [error_count] => 3
    [errors] => Array
        (
            [1] => Unexpected character
            [2] => Unexpected character
            [3] => Unexpected character
        )

)

示例 2

输出

Array
(
    [warning_count] => 0
    [warnings] => Array
        (
        )

    [error_count] => 1
    [errors] => Array
        (
            [0] => The timezone could not be found in the database
        )

)