Home / CSE / PHP - CS :: Operators and Expressions in php

CSE :: PHP - CS

  1. What will be the output of the following PHP code ?

    <?php

    $a = 10;

    $b = 4;

    $c = fun(10,4);

    function fun($a,$b)

    {

    $b = 3;

    return $a - $b + $b - $a;

    }

    echo $a;

    echo $b;

    echo $c;

    ?>

  2. A.

     104

    B.

     410

    C.

     1400

    D.

     4100


  3. What will be the output of the following PHP code ?

    <?php

    $a = "$winner";

    $b = "/$looser";

    echo $a,$b;

    ?>

  4. A.

     $winner/$looser

    B.

     /$looser

    C.

     /

    D.

     $looser


  5. What will be the output of the following PHP code ?

    <?php

    $a = "$winner";

    $b = "$looser";

    echo $a, $b;

    ?>

  6. A.

     $winner$looser

    B.

     $looser

    C.

     \

    D.

     $looser


  7. What will be the output of the following PHP code ?

    <?php

    $a = "$winner";

    $b = "$looser";

    echo $a, $b;

    ?>

  8. A.

     $winner$looser

    B.

     $looser

    C.

     \

    D.

     $looser


  9. What will be the output of the following PHP code ?

    <?php

    $x = 5;

    $y = 10;

    function fun()

    {

    $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y'];

    }

    fun();

    echo $y;

    ?>

  10. A.

     5

    B.

     10

    C.

     15

    D.

     Error


  11. What will be the output of the following PHP code ?

    <?php

    $x = 5;

    $y = 10;

    function fun()

    {

    $y = $GLOBALS['x'] + $GLOBALS['y'];

    }

    fun();

    echo $y;

    ?>

  12. A.

     5

    B.

     10

    C.

     15

    D.

     Error


  13. What will be the output of the following PHP code ?

    <?php

    function fun()

    {

    $x = 0;

    echo $x;

    $x++;

    }

    fun();

    fun();

    fun();

    ?>

  14. A.

     012

    B.

     123

    C.

     000

    D.

     111


  15. What will be the output of the following PHP code ?

    <?php

    function fun()

    {

    static $x = 0;

    echo $x;

    $x++;

    }

    fun();

    fun();

    fun();

    ?>

  16. A.

     012

    B.

     123

    C.

     111

    D.

     Error


  17. What will be the output of the following PHP code ?

    <?php

    static $x = 0;

    function fun()

    {

    echo $x;

    $x++;

    }

    fun();

    fun();

    fun();

    ?>

  18. A.

     012

    B.

     123

    C.

     Nothing

    D.

     Error


  19. What will be the output of the following PHP code ?

    <?php

    $x=0;

    function fun()

    {

    echo $GLOBALS['x'];

    $GLOBALS['x']++;

    }

    fun();

    fun();

    fun();

    ?>

  20. A.

     000

    B.

     012

    C.

     123

    D.

     Error