calculatePrice with parameters price, discount, and tax.price, discount, and tax.calculatePrice function using named arguments in any order.calculatePrice with parameters price, discount, and tax.price, discount, and tax.calculatePrice function using named arguments in any order.price, discount, and tax with the exact values 100, 0.2, and 0.1 respectively.Use the $ sign to create variables and assign the exact values given.
calculatePrice that takes three parameters: price, discount, and tax. The function should return the final price calculated as price - (price * discount) + (price * tax).Use the function keyword and return the calculation inside the function.
calculatePrice function using named arguments with the variables discount, tax, and price in this exact order. Store the result in a variable called finalPrice.Use the syntax parameterName: value to pass named arguments in the function call.
finalPrice using echo.Use echo $finalPrice; to display the result.
What is the main benefit of using named arguments in PHP functions?
Which of the following is the correct syntax to call a function greet with named arguments name and age?
function greet($name, $age) { return "Hello $name, you are $age."; }paramName: value when calling functions.name: "Alice" and age: 30, which is correct syntax.What will be the output of the following PHP code?
function describe($color, $shape) {
return "A $color $shape.";
}
echo describe(shape: "circle", color: "red");shape is "circle" and color is "red". The return string is "A $color $shape.", so it becomes "A red circle.".Identify the error in the following PHP code using named arguments:
function multiply($x, $y) {
return $x * $y;
}
echo multiply(y: 5, 3);y: 5 first, then a positional argument 3, which is invalid syntax.Given the function below, which call correctly uses named arguments to skip the optional country parameter and specify city only?
function locationInfo(string $city, string $country = "USA") {
return "$city, $country";
}country parameter has a default value, so it can be skipped.country and sets citylocationInfo(city: "Boston"), skipping country and using default "USA".Pass the test and this pattern moves unknown