How do I see ** all ** current defined variables in PHP?

I need a way to see all the specific variables of the current PHP instance.
Currently, I mean all global, all local for this area and all local residents in other areas.
Is there anything built?

+3
source share
2 answers

For everything in the current area:

print_r(get_defined_vars());

I don’t think there is a solution to reset all variables from all areas, because you will need to actually run these functions / methods in order to get a complete and intact map of all available variables (variables could be created, added and deleted at runtime).

, , - , .

?

+8

var_dump ($ GLOBALS);

, . "" .

{
    $a = new myClass();
    do stuff
    $a->destroy();
}
print "$a has no meaning in this context";
+2

Source: https://habr.com/ru/post/1745171/


All Articles