PHP Functions
- What will be the output of the following PHP code ?
<?php
function fun($str)
{
echo "hello\n".$str;
function Z()
{
echo "Inside block executed...\n";
}
}
function Z()
{
echo "Outside block executed...\n";
}
Z();
fun("Interview Mania");
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Function Z is declared twice.
- What will be the output of the following PHP code ?
<?php
function fun($str)
{
echo "Hello ".$str;
function m()
{
echo "\nBlock m executed...";
}
}
fun("Interview Mania");
m();
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
m is declared as fun() is executed first.
- What will be the output of the following PHP code ?
<?php
function calculation($n1, $n2)
{
$n3 = $n1 * $n2;
}
$R = calculation(12, 25);
echo $R;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Function does not return anything.
- What will be the output of the following PHP code ?
<?php
function calculate($n1, $n2)
{
$n3 = $n1 * $n2;
return $n3;
}
$R = calculate(22, 23);
echo $R;
?>
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Function returns $n3.