Home » PHP » PHP Functions » Question
  1. What will be the output of the following PHP code?
    <?php
    function calc1(&$n)
    {
    $n += 7;
    }
    function calc2(&$n)
    {
    $n += 8;
    }
    $OrignalNumber = 12;
    calc1( $OrignalNumber );
    echo "Original Number is $OrignalNumber\n";
    calc2( $OrignalNumber );
    echo "Original Number is $OrignalNumber\n";
    ?>
    1. Original Number is 27
      Original Number is 19
    2. Original Number is 12
      Original Number is 19
    3. Original Number is 19
      Original Number is 27
    4. Original Number is 15
      Original Number is 12
    5. None of these
Correct Option: C

calc2() passes value of the variable by reference.



Your comments will be displayed only after manual approval.