I once saw a framework or code from some PHP that had an error handler (class or function) that would show an error message, the line number the error occurred on as well as the actual source code, if there was some sort of error in the code, it would show the line or a few lines from the actual PHP file that caused the error. it was really cool, I understand that you would not want to ever do this on a live production server/site but for debugging, it was very nice and something I have never seen before.
I cannot remember where I saw this or how it was done. If you have any ideas on how to do something similar, I would love to have a nice little class for error handling that would do stuff like that, please share any code, ideas, etc on this if you can, really appreciate any help, thank you!
What you are talking of is a stack trace, in PHP you can retrieve it with debug_backtrace().
Most framework have their own way to display stack trace, but basicly they all use such functions.
However, what you are really looking for is Xdebug it is a debugger and a profilter for PHP, and will let you run code step by step.
Edit:
If you want to handle error to provide your own way to work with, you have to use
set_error_handler()andset_exception_handler()A simple example:
Trying this on cli, should show you:
Note that’s a really basic usage, but it does the trick. You may need to do more work if you intend to handle
E_ERROR,E_PARSE, etc. and you may need to useregister_shutdown_function()