PHP error_get_last() 関数

PHP エラー・リファレンス

発生した最後のエラーを返します:

<?php
echo $test;
print_r(error_get_last());
?>

上のコードの出力は、次の通り:

Array
(
    [type] => 8
    [message] => Undefined variable: test
    [file] => C:\webfolder\test.php
    [line] => 2
)


定義と用法

error_get_last() 関数は、発生した最後のエラーを返します(連想配列で)。

連想配列には、次の4つのキーがあります:


構文

error_get_last();

技術内容
返り値: 最後に発生したエラーについての情報を連想配列で返します。連想配列のキーは "type"、"message"、"file" および "line" です。
PHP バージョン: 5.2+

PHP エラー・リファレンス