Php/docs/exception.gettrace

提供:Dev Guides
< Php
移動先:案内検索

Exception::getTrace

(PHP 5, PHP 7, PHP 8)

Exception::getTraceスタックトレースを取得する


説明

final public Exception::getTrace ( ) : array

例外のスタックトレースを返します。


パラメータ

この関数にはパラメータはありません。


返り値

例外のスタックトレースを配列で返します。


例1 Exception::getTrace() の例

<?phpfunction test() { throw new Exception;}try { test();} catch(Exception $e) { var_dump($e->getTrace());}?>

上の例の出力は、 たとえば以下のようになります。


array(1) {
  [0]=>
  array(4) {
    ["file"]=>
    string(22) "/home/bjori/tmp/ex.php"
    ["line"]=>
    int(7)
    ["function"]=>
    string(4) "test"
    ["args"]=>
    array(0) {
    }
  }
}

参考