nerdexam
Zend

200-710 · Question #33

Which line of code can be used to replace the INSERT comment in order to output "hello"? class C { public $ello = 'ello'; public $j; public $m; function __construct($y) { $this->c = static…

The correct answer is B. return $f(). "ello". See the full explanation below for the reasoning.

Closures

Question

Which line of code can be used to replace the INSERT comment in order to output "hello"? class C { public $ello = 'ello'; public $j; public $m; function __construct($y) { $this->c = static function($f) { // INSERT LINE OF CODE HERE }; } $this->m = function() { return "h"; }; } $x = new C("h"); $j = ($x->c); echo $f($x->m);

Options

  • Areturn $this->m(). "ello";
  • Breturn $f(). "ello";
  • Creturn "h". $this->ello;
  • Dreturn $y . "ello";

How the community answered

(34 responses)
  • A
    3% (1)
  • B
    82% (28)
  • C
    6% (2)
  • D
    9% (3)

Topics

#static closures#closure binding#callable variables#anonymous functions

Community Discussion

No community discussion yet for this question.

Full 200-710 Practice