Named arguments allow you to pass input data into a function/method based on their argument name instead of the argument order. This is a useful feature no we don’t have to remember the order of the arguments and we don’t have to pass the default arguments to pass something which is in the end or middle.
PHP 8.0 allows named parameters in function/method calls in addition to traditional positional parameters. Below is an example.
function sum($a, $b){
return a+b;
}
test(b: 1, a: 1); // 2
function sum($a=10, $b){
return a+b;
}
test(b: 10); // 20