Free 200-550 Exam Braindumps
Zend Certified PHP Engineer Questions 106–110 (page: 23)

Updated On: 9-Feb-2026

Given the following code, how can we use both traits A and B in the same class? (select all that apply)
trait A {
public function hello() {
return "hello";
}
public function world() {
return "world";
}
}
trait B {
public function hello() {
return "Hello";
}
public function person($name) {
return ":$name";
}
}

  1. Rename the A::hello() method to a different name using A::hello as helloA;
  2. Use B::hello() instead of A 's version using B::hello insteadof A
  3. Use B::hello() instead of A 's version using use B::hello
  4. Rename the A::hello() method to a different name using A::hello renameto helloA;
  5. None of the above (both can be used directly)

Answer(s): B



In the following code, which line should be changed so it outputs the number 2:
class A {
protected $x = array(); /* A */
public function getX() { /* B */
return $this->x; /* C */
}
}
$a = new A(); /* D */
array_push($a->getX(), "one");
array_push($a->getX(), "two");
echo count($a->getX());

  1. No changes needed, the code would output 2 as is
  2. Line A, to: protected &$x = array();
  3. Line B, to: public function &getX() {
  4. Line C, to: return &$this->x;
  5. Line D, to: $a =& new A();

Answer(s): C



What is the output of the following code?
class A {
public $a = 1;
public function __construct($a) { $this->a = $a; }
public function mul() {
return function($x) {
return $this->a*$x;
};
}
}
$a = new A(2);
$a->mul = function($x) {
return $x*$x;
};
$m = $a->mul();
echo $m(3);

  1. 9
  2. 6
  3. 0
  4. 3

Answer(s): B



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



Viewing page 23 of 46
Viewing questions 177 - 184 out of 223 questions


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

AI Tutor AI Tutor 👋 I’m here to help!