Complete the code to call the function using a named argument for name.
<?php
function greet(string $name) {
echo "Hello, $[1]!";
}
greet(name: "Alice");
?>The function uses the parameter name. Using name as a named argument matches the parameter.
Complete the function call using a named argument for age.
<?php
function showAge(int $age) {
echo "Age: $[1]";
}
showAge(age: 30);
?>The named argument age matches the function parameter age.
Fix the error by completing the function call with the correct named argument for city.
<?php
function printCity(string $city) {
echo "City: $[1]";
}
printCity(city: "Paris");
?>The named argument must match the parameter city to avoid errors.
Fill both blanks to call the function with named arguments for firstName and lastName.
<?php
function fullName(string $firstName, string $lastName) {
echo "Name: $[1] $[2]";
}
fullName([1]: "John", [2]: "Doe");
?>The named arguments must match the parameter names firstName and lastName.
Fill all three blanks to call the function with named arguments for title, author, and year.
<?php
function bookInfo(string $title, string $author, int $year) {
echo "Book: $[1], Author: $[2], Year: $[3]";
}
bookInfo([1]: "1984", [2]: "Orwell", [3]: 1949);
?>Named arguments must match the parameter names title, author, and year exactly.