Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a PHP equivalent of Python's traceback.format_exc()?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading