MCQs for Exams

✅ Q1

Which statement is used for multiple conditions?

A) echo
B) if-else
C) print
D) break

👉 Answer: B


✅ Q2

What is the output?

$x = 10;
echo ($x > 5) ? "Yes" : "No";

A) No
B) Yes
C) Error
D) Nothing

👉 Answer: B


✅ Q3

Which is true about switch?

A) Uses strict comparison
B) Needs break
C) Returns value
D) Works only with numbers

👉 Answer: B


✅ Q4

Which feature belongs to match?

A) Requires break
B) Loose comparison
C) Returns value
D) Works only in PHP 5

👉 Answer: C


✅ Q5

What will this output?

$day = "Sunday";echo match($day) {
"Monday" => "Work",
"Sunday" => "Holiday",
};

A) Work
B) Holiday
C) Error
D) Nothing

👉 Answer: B


✅ Q6

Which operator is shorthand for if-else?

A) ==
B) ??
C) ?:
D) =>

👉 Answer: C