Home / CSE MCQs / PHP MCQs :: PHP Basics

CSE MCQs :: PHP MCQs

  1. Which of the following php statement/statements will store 111 in variable num?
    i) int $num = 111;
    ii) int mum = 111;
    iii) $num = 111;
    iv) 111 = $num;
  2. A.
    Both (i) and (ii)
    B.
    All of the mentioned.
    C.
    Only (iii)
    D.
    Only (i)

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. What will be the output of the following php code
    < ?php  $num  = 1; $num1 = 2; print $num . "+". $num1 ; ?>
  4. A.
    3
    B.
    1+2
    C.
    1.+.2
    D.
    Error

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What will be the output of the following php code?
    < ?php  $num  = "1"; $num1 = "2"; print $num+$num1 ; ?>
  6. A.
    3
    B.
    1+2
    C.
    Error
    D.
    12

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which of following variables can be assigned a value to it?
    (i) $3hello
    (ii) $_hello
    (iii) $this
    (iv) $This
  8. A.
    All of the mentioned
    B.
    Only (ii)
    C.
    (ii), (iii) and (iv)
    D.
    (ii) and (iv)

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output of the following code?
    < ?php  $foo = 'Bob';               $bar = &$foo;               $bar = "My name is $bar";   echo $bar; echo $foo; ?>
  10. A.
    Error
    B.
    My name is BobBob
    C.
    My name is BobMy name is Bob
    D.
    My name is Bob Bob

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?
  12. A.
    12
    B.
    1
    C.
    Error
    D.
    5

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. Which of the following PHP statements will output Hello World on the screen?
    (i) echo ("Hello World);
    (ii) print ("Hello World);
    (iii) printf ("Hello World);
    (iv) sprintf ("Hello World);
  14. A.
    (i) and (ii)
    B.
    (i), (ii) and (iii)
    C.
    All of the mentioned
    D.
    (i), (ii) and (iv)

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. What will be the output of the following PHP code?
    < ?php  $color = "maroon"; $var = $color[2]; echo "$var" ; ?>
  16. A.
    a
    B.
    Error
    C.
    $var
    D.
    r

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What will be the output of the following PHP code?
    < ?php  $score = 1234; $scoreboard = (array) $score; echo $scoreboard[0]; ?>
  18. A.
    1
    B.
    Error
    C.
    1234
    D.
    2

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What will be the output of the following PHP code?
    < ?php  $total = "25 students"; $more = 10; $total = $total + $more; echo "$total" ; ?>
  20. A.
    Error
    B.
    35 students
    C.
    35
    D.
    25 students

    View Answer

    Workspace

    Discuss Discuss in Forum