visitor pattern in PHP

user1950349

I was asked this interview question recently:

"Which PHP mechanism allows to use visitor pattern to sort an array?".

I am not sure what mechanism we have in PHP? Can anyone provide an example of its use as well?

Michail Strokin

My guess is:

In the Visitor pattern, one class calls a function in another class with the current instance of itself. The called class has special functions for each class that can call it.

Accorting to php docs:

uasort — Sort an array with a user-defined comparison function and maintain index association

uasort($collection, array('MyClassName', 'mySortMethod')); 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related