Warning: array_filter() expects parameter 2 to be a valid callback

时间:2016-06-11 07:08:31   收藏:0   阅读:431
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;
    });
}


原文:http://lybing.blog.51cto.com/3286625/1787870

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!