PHP func_get_arg function

The func_get_arg, when passed an integer, will return the argument passed to the current function, indexed by that integer. To process a variable argument list, you could use code such as:

for ($index = 0; index < func_num_args(); index++) {
   $arg = func_get_arg(index);
}

The limitation of this function is that it does not take into account the default arguments when a value has not been passed by the call to the function.

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.