Bird
0
0

What does a nullable type declaration like ?int mean in a PHP function parameter?

easy📝 Conceptual Q11 of 15
PHP - Functions
What does a nullable type declaration like ?int mean in a PHP function parameter?
AThe parameter is optional and defaults to zero.
BThe parameter can be either an integer or null.
CThe parameter can be any type except integer.
DThe parameter must always be an integer, never null.
Step-by-Step Solution
Solution:
  1. Step 1: Understand nullable type syntax

    The ? before int means the parameter can accept null or an int value.
  2. Step 2: Interpret the meaning in function parameters

    This allows the function to safely accept missing or empty values represented by null.
  3. Final Answer:

    The parameter can be either an integer or null. -> Option B
  4. Quick Check:

    Nullable type = int or null [OK]
Quick Trick: Nullable means type or null allowed, check for ? before type [OK]
Common Mistakes:
  • Thinking nullable means optional parameter
  • Assuming nullable excludes null values
  • Confusing nullable with default values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes