
error_get_last() 函数以关联数组的形式获取最后发生的错误。关联数组包含四个键 -
[type] - 描述错误type
[message] - 描述错误消息
[file] - 描述发生错误的文件 p>
-
[line] - 描述发生错误的行
立即学习“PHP免费学习笔记(深入)”;
语法
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











