Bird
0
0

Find the error in this PHP code snippet:

medium📝 Debug Q14 of 15
PHP - Operators
Find the error in this PHP code snippet:
$x = true;
$y = false;
if ($x || ! $y) {
echo 'True';
else {
echo 'False';
}
AMissing closing brace for if block
BMissing semicolon after echo statement
CIncorrect use of logical OR operator
DMissing closing parenthesis in if condition
Step-by-Step Solution
Solution:
  1. Step 1: Check the if statement syntax

    The if condition has correct parentheses and logical operators.
  2. Step 2: Check the braces for if-else blocks

    The if block opens with { but does not have a closing } before the else block starts.
  3. Final Answer:

    Missing closing brace for if block -> Option A
  4. Quick Check:

    Braces must match for if-else [OK]
Quick Trick: Count opening and closing braces carefully [OK]
Common Mistakes:
  • Assuming missing parenthesis causes error
  • Thinking logical OR syntax is wrong
  • Ignoring missing brace errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes