How to get a list of available arguments for a PHP function?

Is there a way to get the available arguments for a PHP function?

Example: I want to call function1($arg1, $arg2=null). How can I find out, before calling a function, the number of arguments this function takes, and, if possible, which arguments?

As you can see, I am dynamically calling functions.

+3
source share
3 answers

You can use the following functions inside the called function to determine how many arguments were passed and get their values. I'm not sure how you can check what arguments the function expects.

func_num_args ()

func_get_arg ()

func_get_args

+1
source

, ReflectionFunction. PHP , .

+1

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


All Articles