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 5 Question 105 Discussion

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);
D) MyObject should implement method __invoke
A) MyObject should extend class Closure
B) MyObject should implement interface Callable
C) MyObject should implement method __call

Zend 200-710 Exam - Topic 5 Question 105 Discussion

Actual exam question for Zend's 200-710 exam
Question #: 105
Topic #: 5
[All 200-710 Questions]

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

Show Suggested Answer Hide Answer
Suggested Answer: D

Contribute your Thoughts:

0/2000 characters
Velda
8 days ago
I agree, __invoke is the way to go!
upvoted 0 times
...
Regenia
13 days ago
D is definitely the best option here.
upvoted 0 times
...
Shaquana
19 days ago
C doesn't fit the context well.
upvoted 0 times
...
Cecilia
24 days ago
I feel like D is the most straightforward.
upvoted 0 times
...
An
29 days ago
B could work too, but not ideal.
upvoted 0 times
...
Denny
1 month ago
A is interesting, but not necessary.
upvoted 0 times
...
Helga
1 month ago
Yeah, __invoke makes it callable.
upvoted 0 times
...
Cherry
1 month ago
I think D is the right choice.
upvoted 0 times
...
Miesha
2 months ago
No way, __call won't help here!
upvoted 0 times
...
Major
2 months ago
I think option B is also valid, but D is more straightforward.
upvoted 0 times
...
Marisha
2 months ago
Wait, can a class really be called like that?
upvoted 0 times
...
Lino
2 months ago
Totally agree, option D is the way to go!
upvoted 0 times
...
Lashanda
2 months ago
MyObject needs to implement __invoke for array_walk to work.
upvoted 0 times
...
Nan
3 months ago
I thought implementing __call was important for handling dynamic method calls, but I'm not sure if that's relevant here.
upvoted 0 times
...
Yolando
3 months ago
I feel like we had a practice question about closures and callable interfaces, but I can't recall the exact details.
upvoted 0 times
...
Omer
3 months ago
I'm not entirely sure, but I remember something about classes needing to be callable for array_walk. Maybe it's option B?
upvoted 0 times
...
Ciara
3 months ago
I think MyObject needs to implement __invoke, right? That sounds familiar from the callable examples we went over.
upvoted 0 times
...

Save Cancel