Home » PHP » PHP Functions » Question
  1. What will be the output of the following PHP code?
    <?php
    $option2 = "Hey";
    function fun($option1)
    {
    echo $option1;
    echo $option2;
    }
    fun("Welcome");
    ?>
    1. Error
    2. Welcome
    3. Hey
    4. Nothing
    5. None of these
Correct Option: B

If you want to put some variables in function that was not passed by it, you must use “global”. Inside the function type global $option2.



Your comments will be displayed only after manual approval.