Bird
0
0

Examine the following PHP code snippet:

medium📝 Debug Q6 of 15
PHP - Variables and Data Types
Examine the following PHP code snippet:
$var = null
if ($var === null) {
echo 'Null value';
}

What is the issue with this code?
AMissing semicolon after <code>$var = null</code>
BUsing strict comparison operator <code>===</code> incorrectly
CEcho statement syntax is invalid
DVariable <code>$var</code> is not declared
Step-by-Step Solution
Solution:
  1. Step 1: Check PHP statement syntax

    Every PHP statement must end with a semicolon (;).
  2. Step 2: Identify missing semicolon

    The line $var = null lacks a semicolon at the end, causing a syntax error.
  3. Step 3: Verify other parts

    The strict comparison === is valid, echo syntax is correct, and $var is declared.
  4. Final Answer:

    Missing semicolon after $var = null -> Option A
  5. Quick Check:

    Statements must end with ';' [OK]
Quick Trick: Always end PHP statements with a semicolon [OK]
Common Mistakes:
  • Omitting semicolon at end of statements
  • Confusing assignment '=' with comparison '==='
  • Assuming variables need explicit declaration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes