Commerce

Basic Php MCQs

Practice Basic Php MCQs for competitive exams.

Basic Php MCQs

Practice questions from this topic.

Who is the father of PHP?

  1. A. Rasmus Lerdorf
  2. B. Willam Makepiece
  3. C. Drek Kolkevi
  4. D. List Barely
Report Error

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

  1. A. a is 3 and b is 4
  2. B. a is 4 and b is 3
  3. C. Both are 3
  4. D. Both are 4
Report Error

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

  1. A. 12
  2. B. 1
  3. C. Error
  4. D. 5
Report Error

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

  1. A. 1 and 2
  2. B. 1, 2 and 3
  3. C. All of the mentioned
  4. D. None of the mentioned
Report Error

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

  1. A. Only 1
  2. B. 1, 2 and 4
  3. C. 2, 3 and 4
  4. D. All of the mentioned.
Report Error

Which of the below symbols is a newline character?

  1. A. r
  2. B. n
  3. C. /n
  4. D. /r
Report Error

Which statement will output $x on the screen?

  1. A. echo “$x”
  2. B. echo “$$x”
  3. C. echo “/$x”
  4. D. echo “$x;”
Report Error

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

  1. A. $add = $add
  2. B. $add = $add +$add
  3. C. $add = $add + 1
  4. D. $add = $add + $add + 1
Report Error

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”);

  1. A. 1 and 2
  2. B. 1, 2 and 3
  3. C. All of the mentioned
  4. D. 1, 2 and 4
Report Error

What will be the output of the following code?

  1. A. Error
  2. B. My name is BobBob
  3. C. My name is BobMy name is Bob
  4. D. My name is Bob Bob
Report Error

Which of following variables can be assigned a value to it? 1. $3hello 2. $_hello 3. $this 4. $This

  1. A. All of the mentioned
  2. B. Only 2
  3. C. 2, 3 and 4
  4. D. 2 and 4
Report Error

What will be the output of the following php code?

  1. A. 3
  2. B. 1+2
  3. C. 1.+.2
  4. D. Error
Report Error