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());
- No changes needed, the code would output 2 as is
- Line A, to: protected &$x = array();
- Line B, to: public function &getX() {
- Line C, to: return &$this->x;
- Line D, to: $a =& new A();
Reveal Solution
Next Question