Re: [PHP4BETA] passing a method to usort

From: Date: Tue, 29 Feb 2000 21:42:31 +0000
Subject: Re: [PHP4BETA] passing a method to usort
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-11207@lists.php.net to get a copy of this message
chagenbu@wso.williams.edu wrote: > > Should this work in php4? > > <?php > > error_reporting(E_ALL); > > class Sort { > function cmp ($a, $b) { > if ($a == $b) return 0; > elseif ($a > $b) return 1; > else return -1; > } > } > > $list = array(1, 4, 5, 2, 6, 3); > echo implode('<br>', $list); > echo '<hr>'; > > usort($list, 'Sort::cmp'); > > echo implode('<br>', $list); > ?> > > It seems to just ignore the function completely, and doesn't touch the list. It is the Zend compiler that recognizes "::" (as opposed to the executor), so it's no wonder your example doesn't work. We could patch call_user_function{,_ex} to look for "::" in the function name though. - Stig

« previous php.version4 (#11207) next »