Warning:  array_filter() expects parameter 2 to be a valid callback, function 'checkMonth' not found or invalid function name in path\to\xxxModel.php on line 36

下面是相关的Code片段 - php版本:5.6:

function checkMonth($v){
    return $v == $this->month;
}
function getByMonth($month){
    $ret = $this->allRet;
    $this->month = isset($month)?$month:date("m");
    return array_filter($ret, "checkMonth");
}


转而用匿名方法是正常的,所以不晓得是不是PHP版本的问题:

function getCourseByMonth($month){
    $ret = $this->allRet;
    $month = isset($month)?$month:date("m");
    return array_filter($ret, function($item) use($month){
        return date("m", strtotime($item[1])) == $month;
    });
}