Current Location: Home> Function Categories> getTrace

getTrace

Returns an array containing information about all functions that were running when the exception was thrown.
Name:getTrace
Category:Uncategorized
Programming Language:php
One-line Description:Returns an array containing information about all functions that were running when the exception was thrown.

Definition and usage

getTrace() method returns the stack trace as an array.

The stack trace contains information about all functions running at a given moment. The stack trace provided by this method contains stack information when an exception is thrown.

Related pages

Tutorial: PHP exception

Reference Manual: getTraceAsString() method

Example

Output stack trace:

 <?php
function myFunction ( $num ) {
  throw new Exception ( "An error occurred" ) ;
}

try {
  myFunction ( 5 ) ;
} catch ( Exception $e ) {
  print_r ( $e -> getTrace ( ) ) ;
}
?>

Try it yourself

grammar

 $exception -> getTrace ( )
Similar Functions
Popular Articles