PHP - Conditional StatementsYou want to print "Adult" if age is 18 or more, otherwise "Minor". Which code correctly uses if statement execution flow?Aif $age >= 18 echo 'Adult'; else echo 'Minor';Bif ($age >= 18) echo 'Minor'; else echo 'Adult';Cif ($age > 18) echo 'Adult'; else echo 'Minor';Dif ($age >= 18) { echo 'Adult'; } else { echo 'Minor'; }Check Answer
Step-by-Step SolutionSolution:Step 1: Check condition and output correctnessThe condition must be age >= 18 to print 'Adult'. if ($age >= 18) { echo 'Adult'; } else { echo 'Minor'; } matches this exactly.Step 2: Verify syntax correctnessif ($age >= 18) { echo 'Adult'; } else { echo 'Minor'; } uses parentheses and braces correctly for if-else blocks.Final Answer:if ($age >= 18) { echo 'Adult'; } else { echo 'Minor'; } -> Option DQuick Check:Correct condition and syntax = if ($age >= 18) { echo 'Adult'; } else { echo 'Minor'; } [OK]Quick Trick: Use >= for age check and braces for clarity [OK]Common Mistakes:Using > instead of >= causing wrong outputOmitting parentheses or braces causing syntax errorsSwapping outputs in if and else blocks
Master "Conditional Statements" in PHP9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PHP Quizzes Conditional Statements - Ternary operator - Quiz 13medium Operators - String concatenation operator - Quiz 13medium Output and String Handling - Echo vs print behavior - Quiz 14medium Output and String Handling - String interpolation in double quotes - Quiz 2easy PHP Basics and Execution Model - Why PHP powers most of the web - Quiz 8hard PHP Request Lifecycle - Why variables do not persist between requests - Quiz 15hard Type Handling - Gettype and typeof checks - Quiz 9hard Variables and Data Types - Why variables are needed in PHP - Quiz 3easy Variables and Data Types - Variable naming rules - Quiz 11easy Variables and Data Types - String type (single vs double quotes) - Quiz 11easy