So, I know that with PHP you can define optional parameters (StackOverflow Questions).
What I'm trying to do is the following:
function myFunc($a, $b, $c, $type, $variable_name, $filter, $options)
{
$value = filter_input($type, $variable_name, $filter, $options);
//Do something with $a, $b, $c, and $value
}
Since I am passing in parameters that pertain to the built in function of filter_input
I know that $filter and $options are optional parameters, and to make them optional I would simply assign them a default value. But, I'm not sure what that default value should be. My guess is that $filter should default to FILTER_DEFAULT
, which makes sense, but I can not find any information as to what $options should default to.
Default both $filter and $options to NULL. They are optional for filter_input()
as well, so why assign them a value when filter_input()
will do it for you? If PHP were ever to update the defaults for the function then you'd still be current, too.
Your function would look like this:
function myFunc($a, $b, $c, $type, $variable_name, $filter=NULL, $options=NULL)
{...