Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Zend 200-710 Exam - Topic 6 Question 100 Discussion

Posted by Leigha on Mar 07, 2026 at 11:38 AM

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());

Suggested Answer: C

Get Premium 200-710 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
39 comments · newest first
CH
Cherri 2 days ago
I feel like A is the simplest option. Just works as is.
JU
Julie 7 days ago
Line B makes sense too. It could help with the output.
CE
Cecilia 12 days ago
I disagree. Line C should return a reference.
JO
Jolene 17 days ago
I think A is correct. No changes needed.
CO
Coletta 22 days ago
Nah, I still believe A is the best choice. Simple and effective!
CA
Cathrine 28 days ago
But what about option B? Changing to protected &$x could help.
CO
Cornell 1 month ago
I agree, it should output 2 as is.
LE
Leonora 1 month ago
I think A is correct. No changes needed.
AN
Annice 1 month ago
I’m leaning towards A as well. It should output 2 without changes.
LO
Loren 2 months ago
Line D seems off too. We should change it to reference.
BR
Brock 2 months ago
I disagree, I feel like we need to change line C.
MA
Magnolia 2 months ago
I think A is correct. No changes needed.
NO
Noah 2 months ago
Line C seems unnecessary. Just return the array.
JE
Jerilyn 2 months ago
But what about line B? It could work too.
GL
Glenn 2 months ago
I agree, it outputs 2 without changes.
PE
Pearly 3 months ago
I think A is correct. No changes needed.
LO
Lorrie 3 months ago
Line D looks suspicious, not sure about that one.
LO
Loren 3 months ago
Definitely line A, no changes needed!
DA
Daren 3 months ago
Wait, does this really output 2 as is? Seems off.
TH
Therese 3 months ago
I think line B is the right choice!
LE
Leanna 4 months ago
Line C needs to change to return a reference.
CO
Colette 4 months ago
Definitely line A, it needs to be a reference!
MI
Mitsue 4 months ago
Wait, why would it output 2? I'm confused.
JE
Jess 4 months ago
No way, it works fine as is!
LA
Laquanda 4 months ago
I think line C is the issue here.
CH
Cherry 4 months ago
Line A needs to change to output 2.
JO
Joaquin 5 months ago
I doubt that, it seems like a reference issue.
NU
Nu 6 months ago
Wait, why would it output 2 without changes?
KA
Karima 6 months ago
No way, it should work as is!
PE
Pearly 6 months ago
I think line A should be modified instead.
LA
Lashanda 7 months ago
Line C needs to change to return a reference.
ME
Merrilee 7 months ago
I feel like line C might need to change, but I'm not confident that it would affect the output to be 2.
NA
Naomi 7 months ago
I practiced a similar question where returning by reference was crucial, but I can't recall if it applies here.
NO
Noelia 7 months ago
I'm not entirely sure, but I think changing line B to return by reference might help, though it seems unnecessary.
HE
Helene 7 months ago
I remember that the code should output 2 without any changes, so I think option A is correct.
OS
Osvaldo 7 months ago
I don't think we need to change anything; the code should output 2 as is, right?
FL
Florinda 8 months ago
I'm not entirely sure, but I feel like line A might need to be changed to make the array accessible.
FR
Frankie 8 months ago
I remember a similar question where we had to modify the return type of a function. Maybe changing line B to return by reference could help?
JU
Julene 8 months ago
I think the code actually outputs 0 because the array is empty when we call count.
0/2000 characters

Save Cancel