PHP error_get_last() 函數(shù)
定義和用法
error_get_last() 函數(shù)獲取最后發(fā)生的錯(cuò)誤。
該函數(shù)以數(shù)組的形式返回最后發(fā)生的錯(cuò)誤。
返回的數(shù)組包含 4 個(gè)鍵和值:
- [type] - 錯(cuò)誤類型
- [message] - 錯(cuò)誤消息
- [file] - 發(fā)生錯(cuò)誤所在的文件
- [line] - 發(fā)生錯(cuò)誤所在的行
語法
error_get_last()
例子
<?php echo $test; print_r(error_get_last()); ?>
輸出:
Array ( [type] => 8 [message] => Undefined variable: test [file] => C:\webfolder\test.php [line] => 2 )