nerdexam
Zend

200-710 · Question #224

Given the following PHP function: `` function doSomething(?string $s) { // ... } `` Which of the following values for the $s parameter do NOT yield a type error when calling the doSomething()…

The correct answer is B. `""` (empty string). See the full explanation below for the reasoning.

Functions

Question

Given the following PHP function:
function doSomething(?string $s) {
 // ...
}
Which of the following values for the $s parameter do NOT yield a type error when calling the doSomething() function?

Options

  • Anull
  • B"" (empty string)
  • C0
  • DAll of the above

How the community answered

(45 responses)
  • A
    16% (7)
  • B
    71% (32)
  • C
    4% (2)
  • D
    9% (4)

Topics

#nullable types#type hints#type coercion#function parameters

Community Discussion

No community discussion yet for this question.

Full 200-710 Practice