Is there a function and/or object and/or extension in PHP that will let you view all the variables defined in the current scope? Something like:
var_export($GLOBALS)
but only showing variables in the current symbol table.
You can see scopes and their variables in [[Scopes]] , even closure scopes using console. dir() . It shows you the variables in "[[Scopes]] > Closure", "[[Scopes]] > Global" and even "[[Scopes]] > Script" if the page have scripts reachable. Even with nested closures you can see the nested scopes.
Symbol Table is an important data structure created and maintained by the compiler in order to keep track of semantics of variables i.e. it stores information about the scope and binding information about names, information about instances of various entities such as variable and function names, classes, objects, etc.
These scope rules need a more complicated organization of symbol table than a list of associations between names and attributes. Tables are organized into stack and each table contains the list of names and their associated attributes. Whenever a new block is entered then a new table is entered onto the stack.
get_defined_vars
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With