array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'exception.gettraceasstring.php', 1 => 'Exception::getTraceAsString', ), 'up' => array ( 0 => 'class.exception.php', 1 => 'Exception', ), 'prev' => array ( 0 => 'exception.gettrace.php', 1 => 'Exception::getTrace', ), 'next' => array ( 0 => 'exception.tostring.php', 1 => 'Exception::__toString', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'language/predefined/exception/gettraceasstring.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
Exception::getTraceAsString — スタックトレースを文字列で取得する
この関数にはパラメータはありません。
例外のスタックトレースを文字列で返します。
例1 Exception::getTraceAsString() の例
<?php
function test() {
throw new Exception;
}
try {
test();
} catch(Exception $e) {
echo $e->getTraceAsString();
}
?>
上の例の出力は、 たとえば以下のようになります。
#0 /home/bjori/tmp/ex.php(7): test() #1 {main}