1.
What is the purpose of passing arguments to a function in PHP?
2.
Which keyword is used to define default parameter values in PHP functions?
3.
What will be the output of the following PHP code?
<?php
function greet($name = "Guest") {
return "Hello, $name!";
}
echo greet("Alice");
?
4.
Which of the following statements about returning values from PHP functions is true?
5.
What is the purpose of the return statement in PHP functions?
6.
Which PHP function is used to return a value from a function and terminate its execution?
7.
What will be the output of the following PHP code?
<?php
function add($a, $b) {
return $a + $b;
}
$result = add(5, 3);
echo $result;
?
8.
Which PHP feature allows specifying default values for function arguments?
9.
What will be the output of the following PHP code?
<?php
function sum($a, $b = 5) {
return $a + $b;
}
echo sum(3);
?
10.
Which PHP function is used to check if a function exists before calling it?