> Perhaps this is a question proper for the PHP list, but since
> I have been scratching my head over something I found in Page.php,
> I am asking for edification.
>
> Now I am an old C programmer and I am familiar with Lvalues
> and Rvalues and memory layout and references. And I have
> written many a comparison functions to sort data structures
> to pass as arguments into xxx_cmp() functions.
>
> BUT, I don't understand:
>
> uasort($this->modules[$group], array(&$this,'_ary_sort'));
>
> where the second argument is "normally" supposed to be the
> function to be used for the sorting, user supplied. I just
> don't understand why this works. The knee-jerk call would
> be:
>
> uasort($this->modules[$group],&$this->_ary_sort);
>
> which doesn't work, and messing about with it I got a
> facinating error message coughed up by PHP (probably from
> Zeev) that was in transliterated/ASCII'ized Hebrew. It
> made me pause for a moment to think how marvelous open
> source is......
Yes, the second way was how I did it first. The second gives a reference to
the object, and a separate pointer to the method to use (which I think is
very strange).
> How is this idiom of using an array getting the Lvalue of
> the function???
It's a function of uasort, though there is some new, more elegant code in
the revision of Page.
_alex
> This is probably a waste of everybody's time. I hope
> someone else wondered.
>
>
> --
> Justin Farnsworth
> Eye Integrated Communications
> 321 South Evans - Suite 203
> Greenville, NC 27858 | Tel: (252) 353-0722
|