How can i dump all PHP variables in current scope?
I need this for debugging purposes and need to dump all variables.开发者_StackOverflow Is there a way to get all variables? and is there any way to trace all calls after script ends? without changing my code. Note that i can't use xdebug or anything installable because my script is runnign on a host.
Check out the get_defined_vars function within PHP.
This function returns a multidimensional array containing a list of all defined variables, be them environment, server or user-defined variables, within the scope that get_defined_vars() is called.
You can try using get_defined_vars
.
<?php
$a = 12;
$b = "foo";
$bar = "test";
echo '<pre>';
print_r(get_defined_vars());
?>
精彩评论