nerdexam
Zend

200-710 · Question #134

Given the following code, what is correct? ``php function f(stdClass &$x = NULL) { $x = 42; } $z = new stdClass; f($z); var_dump($z); ``

The correct answer is E. Result is 42. See the full explanation below for the reasoning.

Question

Given the following code, what is correct?
function f(stdClass &$x = NULL) { $x = 42; }
$z = new stdClass;
f($z);
var_dump($z);

Options

  • AError: Typehints cannot be NULL
  • BError: Typehints cannot be references
  • CResult is NULL
  • DResult is object of type stdClass
  • EResult is 42

How the community answered

(38 responses)
  • A
    5% (2)
  • B
    13% (5)
  • C
    5% (2)
  • D
    3% (1)
  • E
    74% (28)

Community Discussion

No community discussion yet for this question.

Full 200-710 Practice