"> What will be the output of the following PHP code ?<?php$n

Home » PHP » PHP Variables » Question
  1. What will be the output of the following PHP code ?
    <?php
    $n = 25;
    function Res()
    {
    $n = 15;
    echo "$n";
    }
    Res();
    echo "$n";
    ?>
    1. 25
    2. 15
    3. 1525
    4. Error
    5. None of these
Correct Option: C

First when the function is called variable n is initialised to 15 so 15 is printed later the global value 25 is printed.



Your comments will be displayed only after manual approval.