Home » PHP » PHP Variables » Question
  1. What will be the output of the following PHP code ?
    <?php
    function Res($p,$q)
    {
    $p = 7;
    $q = 8;
    $r = $p + $q / $q + $p;
    echo "$r";
    }
    Res(8, 7);
    ?>
    1. 7
    2. 8
    3. 15
    4. Error
    5. None of these
Correct Option: C

Value 8, 7 is passed to the function but that is lost because p and q are initialised to 7 and 8 inside the function. Therefore we get the given result.



Your comments will be displayed only after manual approval.