Home / CSE / PHP - CS :: Basic PHP

CSE :: PHP - CS

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

    <?php

    $foo = 'Bob';

    $bar = &$foo;

    $bar = "My name is $bar";

    echo $bar;

    echo $foo;

    ?>

  2. A.

     Error

    B.

     My name is BobBob

    C.

     My name is BobMy name is Bob

    D.

     My name is Bob Bob


  3. Which of the following PHP statements will output Hello World on the screen?
    1. echo (“Hello World”);
    2. print (“Hello World”);
    3. printf (“Hello World”);
    4. sprintf (“Hello World”);

  4. A.

     1 and 2

    B.

     1, 2 and 3

    C.

     All of the mentioned

    D.

     1, 2 and 4


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

    <?php

    $color = "maroon";

    $var = $color[2];

    echo "$var";

    ?>

  6. A.

     a

    B.

     Error

    C.

     $var

    D.

     r


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

    <?php

    $score = 1234;

    $scoreboard = (array) $score;

    echo $scoreboard[0];

    ?>

  8. A.

     1

    B.

     Error

    C.

     1234

    D.

     2


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

    <?php

    $total = "25 students";

    $more = 10;

    $total = $total + $more;

    echo "$total";

    ?>

  10. A.

     Error

    B.

     35 students

    C.

     35

    D.

     25 students


  11. Which of the below statements is equivalent to $add += $add ?

  12. A.

     $add = $add

    B.

     $add = $add +$add

    C.

     $add = $add + 1

    D.

     $add = $add + $add + 1


  13. Which statement will output $x on the screen?

  14. A.

     echo “\$x”;

    B.

     echo “$$x”;

    C.

     echo “/$x”;

    D.

     echo “$x;”;


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

    <?php

    function track()

    {

    static $count = 0;

    $count++;

    echo $count;

    }

    track();

    track();

    track();

    ?>

  16. A.

     123

    B.

     111

    C.

     000

    D.

     011


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

    <?php

    $a = "clue";

    $a .= "get";

    echo "$a";

    ?>

  18. A.

     get

    B.

     true

    C.

     false

    D.

     clueget


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

    <?php

    $a = 5;

    $b = 5;

    span class="sys-fun">echo ($a === $b);

    ?>

  20. A.

     5 === 5

    B.

     Error

    C.

     1

    D.

     False