码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-06-11 07:11:06      阅读:546      评论:0      收藏:0      [点我收藏+]

标签:

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;
    });
}


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

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!