The What
Description
The PHP construct func_get_arg
returns the specified argument that was passed to the function, regardless if it was declared in the function’s parameter list or not. Remember that you can pass more arguments to a function than are specified (declared) in the function’s parameter list.
Parameters
argument_index
- The index number of the argument you want to get. The index starts at zero, which is the first argument passed to the function.
Return Values
It returns the specified argument. If an error occurs, then FALSE
is returned.
Errors and Exceptions
You will get a warning in the following conditions:
- You use it outside of a function.
- The
$argument_index
you specify is less than zero or greater than the number of arguments passed to the function.
Show It in ActionBasic
Let’s see the func_get_arg
function in action. In this video, you will see how it works.
Break. Go rest your noodle for a couple of minutes.
Go DeepPro
In this video, you will go deeper into the instruction.
See It In Popular TechnologiesPro
Let’s look at func_get_arg
in Laravel, Symfony, and WordPress. You will see how prevalent it is used.