11.
What will be the output of the following PHP code?
<?php
function greet() {
echo "Hello, World!";
}
if (function_exists('greet')) {
greet();
} else {
echo "Function does not exist";
}
?
12.
Which PHP feature allows defining functions with variable-length argument lists?
13.
What is the output of the following PHP code?
<?php
function multiply(...$args) {
$result = 1;
foreach ($args as $value) {
$result *= $value;
}
return $result;
}
echo multiply(2, 3, 4);
?
14.
What is the significance of passing functions as arguments in PHP?
15.
Which PHP keyword is used to define functions without specifying their names?
16.
What will be the output of the following PHP code?
<?php
$greet = function($name) {
return "Hello, $name!";
};
echo $greet("John");
?
17.
Which PHP feature allows defining functions within other functions?
18.
What is the output of the following PHP code?
<?php
function outer() {
function inner() {
echo "Inner function";
}
}
inner();
?
19.
Which PHP feature allows defining functions with a variable number of arguments?
20.
What will be the output of the following PHP code?
<?php
function factorial($n) {
$result = 1;
for ($i = 1; $i <= $n; $i++) {
$result *= $i;
}
return $result;
}
echo factorial(5);
?