Examveda
Examveda

What will be the output of the following PHP code ?
<?php
function start($string)
{
    if ($string < 45)
        return 20;
    else
        return 40;
}
$t = start(90);
if ($t < 20)
{
    echo "Have a good day!";
}
else
{
    echo "Have a good night!";
}
?>

A. Have a good day!

B. Have a good night!

C. ERROR

D. None of the mentioned

Answer: Option B

Solution(By Examveda Team)

Function returns 40. this is greater than 20, hence the output.

This Question Belongs to PHP >> Functions

Join The Discussion

Related Questions on Functions