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
Miesha
4 days ago
No way, __call won't help here!
upvoted 0 times
...
Major
10 days ago
I think option B is also valid, but D is more straightforward.
upvoted 0 times
...
Marisha
15 days ago
Wait, can a class really be called like that?
upvoted 0 times
...
Lino
20 days ago
Totally agree, option D is the way to go!
upvoted 0 times
...
Lashanda
25 days ago
MyObject needs to implement __invoke for array_walk to work.
upvoted 0 times
...
Nan
1 month 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
1 month 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
1 month 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
2 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