In OOP where there’s classes and objects, I can use get_object_vars() to get a list of all properties/vars in that class.
In this case, I’m not using OOP. I have some functions and some vars declared outside the functions. When I need to access some of these vars inside a function, I re-declare it as global inside the function. But how do I get a list of all vars declared outside. Is this possible? I’m looking for something like get_object_vars but for non-OOP code.
You can use
get_defined_vars()to get all the variables within the scope thatget_defined_vars()is called.