class DBNews {
public function get_latest_posts($limit){
// code goes here
$posts_array = array();
uasort($posts_array, $this->cmp);
}
public function cmp($a, $b) {
if ($a == $b) {
return 0;
}
return ($a < $b) ? -1 : 1;
}
}
我得到以下警告:PHP uasort在OOP
Warning: uasort() expects parameter 2 to be a valid callback,
no array or string given in
C:\xampp\htdocs\news\admin\functions.php on line 554.
而且第五百五十四行包含uasort($posts_array, $this->cmp)
。
在哪裏使用字符串或數組以及以什麼方式使用?
編輯:如果我使用uasort($posts_array, array($this, 'cmp'));
,我得到以下警告:
uasort() expects parameter 2 to be a valid callback,
array must have exactly two members in
C:\xampp\htdocs\news\admin\functions.php on line 554
uasort($ posts_array,數組($此, 'CMP')); – realization 2013-03-06 10:16:23