Home » PHP » PHP Functions » Question
  1. What will be the output of the following PHP code ?
    <?php
    function fun($str)
    {
    if ($str < 50)
    return 30;
    else
    return 60;
    }
    $p = fun(100);
    if ($p < 30)
    {
    echo "Hello!";
    }
    else
    {
    echo "Hey!";
    }
    ?>
    1. Error
    2. Hello!
    3. Hey!
    4. Hello!
      Hey!
    5. None of these
Correct Option: C

Function returns 60. this is greater than 30, hence the output.



Your comments will be displayed only after manual approval.