PHP Operators and Decision Making Quiz

This quiz tests your knowledge of PHP decision-making structures and operators, helping you understand how PHP controls program flow.

Last Updated :
Discuss
Comments

Question 1

Which operator concatenates two strings in PHP?

  • +

  • .

  • &

  • ,

Question 2

Which logical operator returns true if exactly one operand is true?

  • or

  • xor

  • and

  • !

Question 3

Which logical operator returns true only if both operands are true?

  • or

  • xor

  • and or &&

  • !

Question 4

Which operator is a shorthand for if...else in PHP?

  • &&

  • ?: (ternary)

  • ==

  • switch

Question 5

What happens if none of the cases in a switch Statement match?

  • The first case runs

  • The program throws an error

  • The default case runs if provided

  • Nothing happens

Question 6

What is the purpose of the break statement inside a switch?

  • To restart the switch cases

  • To stop the execution of all cases

  • To stop executing further cases after a match

  • To skip the current case

Question 7

What statement performs different actions based on multiple possible values of a variable?

  • if

  • switch

  • else

  • while

Question 8

How do you check multiple sequential conditions in PHP?

  • if...else

  • switch

  • if...elseif...else

  • for loop

Question 9

What does the if statement do in PHP?

  • Executes code only if a condition is false

  • Executes code only if a condition is true

  • Executes code regardless of any condition

  • Stops program execution

Question 10

What does this PHP code output?

PHP
$age = 20; echo ($age >= 18) ? "Adult" : "Minor"; 


  • Minor

  • Adult

  • Error

  • Nothing

Tags:

There are 10 questions to complete.

Take a part in the ongoing discussion