Bird
0
0

What does the nullable type declaration ?string mean when used in a PHP function parameter?

easy📝 Conceptual Q1 of 15
PHP - Functions
What does the nullable type declaration ?string mean when used in a PHP function parameter?
AThe parameter is optional and defaults to an empty string.
BThe parameter must always be a string and cannot be null.
CThe parameter can accept any data type except null.
DThe parameter can accept a string or null value.
Step-by-Step Solution
Solution:
  1. Step 1: Understand nullable type syntax

    The ?string means the parameter can be either a string or null.
  2. Step 2: Interpret the meaning in function parameters

    This allows passing a string value or explicitly passing null without error.
  3. Final Answer:

    The parameter can accept a string or null value. -> Option D
  4. Quick Check:

    Nullable type = string or null [OK]
Quick Trick: Nullable types allow null or the specified type [OK]
Common Mistakes:
  • Thinking nullable means optional parameter
  • Assuming null is not allowed
  • Confusing nullable with default values

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes