Home » PHP » PHP Introduction » Question
  1. What is the value of $a and $b after the function call?
    <?php
    function doSomething(&$argument)
    {
    $Result = $argument;
    $argument += 1;
    return $Result;
    }
    $n = 5;
    $m = doSomething($n);
    echo "n = " . $n . " and m = " . $m;
    ?>
    1. n = 6
    2. n = 6 and m = 5
    3. m = 6
    4. Error
    5. None of these
Correct Option: B

$n is 6 and $m is 5. The former because $argument is passed by reference, the latter because the return value of the function is a copy of the initial value of the argument.



Your comments will be displayed only after manual approval.