Home > Software engineering >  Is there a PHP equivalent of Python's traceback.format_exc()?
Is there a PHP equivalent of Python's traceback.format_exc()?

Time:04-07

In python, if an exception is thrown, you can call traceback.format_exc() to get a complete stack trace of the exception as a string that can be stored in a variable, as if you were debugging.

In PHP, I do have access to the exception message via catch (Exception $e), but I was wondering if there were a way to get the stack trace of the line that threw the exception, as a string?

Specifically PHP 7.3 would be helpful, as this is the version of our interpreter.

CodePudding user response:

I think debug_backtrace() will do the same in PHP

https://www.php.net/manual/en/function.debug-backtrace.php

I hope it's helpful

  • Related