PHP中的error_get_last()函数

PHP中的error_get_last()函数

error_get_last() 函数以关联数组的形式获取最后发生的错误。关联数组包含四个键 -

  • [type] - 描述错误type

  • [message] - 描述错误消息

  • [file] - 描述发生错误的文件 p>

  • [line] - 描述发生错误的行

语法

error_get_last()

登录后复制

参数

  • NA

返回

error_get_last() 函数返回一个关联数组,描述键“type”、“message”、“file”和“line”的最后一个错误。如果尚未出现错误,则返回 NULL。

示例

以下是示例 -

 实时演示

登录后复制

输出

以下是输出。这里我们在关联数组中显示错误 -

Array
(
[type] => 8
[message] => Undefined variable: res
[file] => /home/cg/root/4127336/main.php
[line] => 2
)
PHP Notice: Undefined variable: res in /home/cg/root/4127336/main.php on line 2

登录后复制

以上就是PHP中的error_get_last()函数的详细内容,更多请关注每日运维网(www.mryunwei.com)其它相关文章!