Current Location: Home> Function Categories> getTraceAsString

getTraceAsString

Returns the same information as getTrace(), but in the form of a string.
Name:getTraceAsString
Category:Uncategorized
Programming Language:php
One-line Description:Returns the same information as getTrace(), but in the form of a string.

Definition and usage

getTraceAsString() method returns the stack trace as a string.

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: getTrace() method

Example

Output stack trace:

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

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

Try it yourself

grammar

 $exception -> getTraceAsString ( )
Similar Functions
Popular Articles