Complete the code to define a function that takes one parameter.
<?php function greet([1]) { echo "Hello, $name!"; } ?>
The parameter must include the $ sign in PHP, so $name is correct.
Complete the code to call the function with the argument 'Alice'.
<?php
function greet($name) {
echo "Hello, $name!";
}
greet([1]);
?>Arguments that are strings must be enclosed in quotes, so "Alice" is correct.
Fix the error in the function definition by completing the parameter list.
<?php function add([1]) { return $a + $b; } ?>
Parameters must be separated by commas and each must have a $ sign, so $a, $b is correct.
Fill both blanks to complete the function call with two arguments.
<?php
function multiply($x, $y) {
return $x * $y;
}
$result = multiply([1], [2]);
?>Arguments can be numbers without quotes, so 5 and 10 are correct.
Fill all three blanks to create a function with a default parameter and call it.
<?php function greetUser([1] = [2]) { echo "Hello, $name!"; } greetUser([3]); ?>
The parameter must have a $ sign, the default value must be a string with quotes, and the argument can be a string with quotes.