Free 200-550 Exam Braindumps (page: 29)

Page 28 of 56

CORRECT TEXT
What is the output of the following code?
class Number {
private $v = 0;
public function __construct($v) { $this->v = $v; }
public function mul() {
return function ($x) { return $this->v * $x; };
}
}
$one = new Number(1);
$two = new Number(2);
$double = $two->mul()->bindTo($one);
echo $double(5);

  1. 5

Answer(s): A



What is the output of the following code?
class Number {
private $v;
private static $sv = 10;
public function __construct($v) { $this->v = $v; }
public function mul() {
return static function ($x) {
return isset($this) ? $this->v*$x : self::$sv*$x;
};
}
}
$one = new Number(1);
$two = new Number(2);
$double = $two->mul();
$x = Closure::bind($double, null, 'Number');
echo $x(5);

  1. 5
  2. 10
  3. 50
  4. Fatal error

Answer(s): C



Which of the following statements about anonymous functions in PHP are NOT true? (Choose 2)

  1. Anonymous functions can be bound to objects
  2. Anonymous functions created within object context are always bound to that object
  3. Assigning closure to a property of an object binds it to that object
  4. Methods bind() and bindTo() of the Closure object provide means to create closures with different binding and scope
  5. Binding defines the value of $this and the scope for a closure

Answer(s): B,C



What will be the result of the following operation?
$a = array_merge([1, 2, 3] + [4=>1, 5, 6]);
echo $a[2];

  1. 4
  2. 3
  3. 2
  4. false
  5. Parse error

Answer(s): B






Post your Comments and Discuss Zend 200-550 exam with other Community members:

200-550 Discussions & Posts