Suppose I have
function test($a, $b, $c=3, $d=4) {
// ...
}
test(1, 2); // $c == 3, $d == 4
test(1, 2, , 9); // syntax error
test(1, 2, null, 9); // $c == null
I want to be able to set $d as 9, but leaving the default value of $c at 3.
Sure, if I know the default value, I can set it. But it's a bad solution because firstly I must know it, and secondly if it gets changed in the function declaration, I have to change it in my code too.
Another solution would be to swap the parameters order, but the code I have to deal with is fairly more complicated and so I would like to know if there is a "standard" solution in PHP, to pass a parameter letting the interpreter use the default value if present.