I have a PHP function that requires can take 3 parameteres… I want to pass it a value for the 1st and 3rd parameters but I want the 2nd one to default…
How can I specify which ones I am passing, otherwise its interpreted as me passing values for the 1st and 2nd slots.
Thanks.
You cannot “not pass” a parameter that’s not at the end of the parameters list :
In your case, you have to pass a value for the 2nd parameter — the default one, ideally ; which, yes, requires your to know that default value.
A possible alternative would be not have your function take 3 parameters, but only one, an array :
And call that function like this :
This would allow you to :
But :