Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: How to dump all local variables in an exception handler

Tags:

php

I'm looking for a method of having my exception handler dump the local variables of the function which the exception was raised in. Is this possible?

like image 882
Aoyama Avatar asked Jan 03 '12 13:01

Aoyama


1 Answers

get_defined_vars() will return an array of all defined variables. You can then loop through each one and dump the contents, or use var_dump( get_defined_vars() ) to dump them en masse.

like image 98
George Cummins Avatar answered Oct 26 '22 00:10

George Cummins