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;
}
}
次の警告が表示されます。
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.
そして 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