Home / CSE / PHP - CS :: Basic PHP

CSE :: PHP - CS

  1. Which of the below symbols is a newline character?

  2. A.

     \r

    B.

     \n

    C.

     /n

    D.

     /r


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

    <?php

    $num = 10;

    echo 'What is her age? \n She is $num years old';

    ?>

  4. A.

     What is her age? n She is $num years old

    B.

     What is her age? She is $num years old

    C.

     What is her age? She is 10 years old

    D.

     What is her age?n She is 10 years old


  5. Which of the conditional statements is/are supported by PHP? 1. if statements 2. if-else statements 3. if-elseif statements 4. switch statements

  6. A.

     Only 1

    B.

     1, 2 and 4

    C.

     2, 3 and 4

    D.

     All of the mentioned.


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

    <?php

    $team = "arsenal";

    switch ($team)

    {

    case "manu":

    echo "I love man u";

    case "arsenal":

    echo "I love arsenal";

    case "manc":

    echo "I love manc";

    }

    ?>

  8. A.

     I love arsenal

    B.

     Error

    C.

     I love arsenalI love manc

    D.

     I love arsenalI love mancI love manu


  9. Which of the looping statements is/are supported by PHP?
    1. for loop
    2. while loop
    3. do-while loop
    4. foreach loop

  10. A.

     1 and 2

    B.

     1, 2 and 3

    C.

     All of the mentioned

    D.

     None of the mentioned


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

    <?php

    $user = array("Ashley", "Bale", "Shrek", "Blank");

    for ($x=0; $x < count($user); $x++)

    {

    if ($user[$x] == "Shrek") continue;

    printf ($user[$x]);

    }

    ?>

  12. A.

     AshleyBale

    B.

     AshleyBaleBlank

    C.

     ShrekBlank

    D.

     Shrek


  13. If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?

  14. A.

     12

    B.

     1

    C.

     Error

    D.

     5


  15. What is the value of $a and $b after the function call?

    <?php

    function doSomething( &$arg )

    {

    $return = $arg;

    $arg += 1;

    return $return;

    }

    $a = 3;

    $b = doSomething( $a );

    ?>

  16. A.

     a is 3 and b is 4

    B.

     a is 4 and b is 3

    C.

     Both are 3

    D.

     Both are 4


  17. Who is the father of PHP?

  18. A.

     Rasmus Lerdorf

    B.

     Willam Makepiece

    C.

     Drek Kolkevi

    D.

     List Barely


  19. How does the identity operator === compare two values?

  20. A.

     It converts them to a common compatible data type and then compares the resulting values

    B.

     It returns True only if they are both of the same type and value

    C.

     If the two values are strings, it performs a lexical comparison

    D.

     It bases its comparison on the C strcmp function exclusively

    E.

     It converts both values to strings and compares them