Free 200-550 Exam Braindumps (page: 11)

Page 10 of 56

What is the output of the following code?
class Test {
public function __call($name, $args)
{
call_user_func_array(array('static', "test$name"), $args);
}
public function testS($l) {
echo "$l, ";
}
}
class Test2 extends Test {
public function testS($l) {
echo "$l, $l, ";
}
}
$test = new Test2();
$test->S('A');

  1. A,
  2. A, A,
  3. A, A, A,
  4. PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback

Answer(s): B



Which of the following tasks can be achieved by using magic methods? (Choose 3)

  1. Initializing or uninitializing object data
  2. Creating a new stream wrapper
  3. Creating an iterable object
  4. Processing access to undefined methods or properties
  5. Overloading operators like +, *, etc.
  6. Converting objects to string representation

Answer(s): A,D,F



How should class MyObject be defined for the following code to work properly? Assume $array is an array and MyObject is a user-defined class.
$obj = new MyObject();
array_walk($array, $obj);

  1. MyObject should extend class Closure
  2. MyObject should implement interface Callable
  3. MyObject should implement method __call
  4. MyObject should implement method __invoke

Answer(s): D



Consider the following code. What change must be made to the class for the code to work as written?
class Magic {
protected $v = array("a" => 1, "b" => 2, "c" => 3);
public function __get($v) {
return $this->v[$v];
}
}
$m = new Magic();
$m->d[] = 4;
echo $m->d[0];

  1. Nothing, this code works just fine.
  2. Add __set method doing $this->v[$var] = $val
  3. Rewrite __get as: public function __get(&$v)
  4. Rewrite __get as: public function &__get($v)
  5. Make __get method static

Answer(s): D






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

200-550 Discussions & Posts