0

In php, how to get all variables defined in a method or function. There is the get_defined_vars() function, which gives variables of the function where I am printing(dump). But I need a function which takes a method name as argument and returns all variables in it.

Example: giveMeAllVariablesDefinedInside($class, $method) or something like this.

5
  • get_class_vars($class_name )? Commented Sep 5, 2017 at 7:53
  • 1
    Given you can get the information you want to have. What would you like to do with them? Sounds like a XY-Problem. Commented Sep 5, 2017 at 8:01
  • I just need data of this variable to use in my future coding. I am going parse my classes and show up. Commented Sep 5, 2017 at 8:02
  • Why not just write the data to a property from inside the method? Commented Sep 5, 2017 at 8:03
  • @gogagubi did you got a solution for this? Commented Jul 17, 2019 at 10:35

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

No I don't need parameters. I need list of variables defined inside method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.