CommerceBasic Php MCQs
Practice Basic Php MCQs for competitive exams.
Basic Php MCQs
Practice questions from this topic.
Who is the father of PHP?
- A. Rasmus Lerdorf
- B. Willam Makepiece
- C. Drek Kolkevi
- D. List Barely
Correct Answer: A
What is the value of $a and $b after the function call?
- A. a is 3 and b is 4
- B. a is 4 and b is 3
- C. Both are 3
- D. Both are 4
Correct Answer: B
If $a = 12 what will be returned when ($a == 12) ? 5 : 1 is executed?
- A. 12
- B. 1
- C. Error
- D. 5
Correct Answer: D
Which of the looping statements is/are supported by PHP? 1. for loop 2. while loop 3. do-while loop 4. foreach loop
- A. 1 and 2
- B. 1, 2 and 3
- C. All of the mentioned
- D. None of the mentioned
Correct Answer: C
Which of the conditional statements is/are supported by PHP? 1. if statements 2. if-else statements 3. if-elseif statements 4. switch statements
- A. Only 1
- B. 1, 2 and 4
- C. 2, 3 and 4
- D. All of the mentioned.
Correct Answer: D
Which of the below symbols is a newline character?
- A. r
- B. n
- C. /n
- D. /r
Correct Answer: B
Which statement will output $x on the screen?
- A. echo “$x”
- B. echo “$$x”
- C. echo “/$x”
- D. echo “$x;”
Correct Answer: A
Which of the below statements is equivalent to $add += $add ?
- A. $add = $add
- B. $add = $add +$add
- C. $add = $add + 1
- D. $add = $add + $add + 1
Correct Answer: B
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”);
- A. 1 and 2
- B. 1, 2 and 3
- C. All of the mentioned
- D. 1, 2 and 4
Correct Answer: B
What will be the output of the following code?
- A. Error
- B. My name is BobBob
- C. My name is BobMy name is Bob
- D. My name is Bob Bob
Correct Answer: C
Which of following variables can be assigned a value to it? 1. $3hello 2. $_hello 3. $this 4. $This
- A. All of the mentioned
- B. Only 2
- C. 2, 3 and 4
- D. 2 and 4
Correct Answer: D
What will be the output of the following php code?
- A. 3
- B. 1+2
- C. 1.+.2
- D. Error
Correct Answer: B