The reason for this restriction is that otherwise it would be impossible to determine which arguments you are trying to pass. Let's assume the following function:
function foo($first = 'default', $second = 'default', $third) { ... }
And now we're calling it with foo('custom value', 'another value');
. another value
is obviously the value for $third
, but what parameter does custom value
stand for? $first
or $second
? You can only guess and guessing is a really bad thing for a programming language to do, as it limits predictability for the programmer.
A way to fix that would be named parameter passes. In PHP this could look like foo($first='custom value', 'another value');
. Now it's clear which default value you're trying to overwrite. Python supports syntax like that, but PHP does not (yet). There has been some discussion to add this feature, I think, but it hasn't been done so far.