我正在努力将我的代码更新为PHP 7兼容,并且“Too few arguments”错误是我一直在修复的常见错误。我似乎无法弄清楚为什么它会发生这个功能,但是:
function processDates(){
global $post;
if(get_field('seminar_end_date')){
$datestart = get_field('seminar_start_date');
$dateend = get_field('seminar_end_date');
if($datestart == $dateend){
return date('M j, Y',strtotime($datestart));
} else {
$daterange = combineDates($datestart,$dateend);
return $daterange;
}
} else {
$daterange = '<strong>Wk 1:
</strong>'.combineDates(get_field('weekend_1_start'),get_field('weekend_1_end'));
if(get_field('weekend_2_start')) $daterange .= '<br /><strong>Wk 2:</strong> '.combineDates(get_field('weekend_2_start'),get_field('weekend_2_end'));
if(get_field('weekend_3_start')) $daterange .= '<br /><strong>Wk 3:</strong> '.combineDates(get_field('weekend_3_start'),get_field('weekend_3_end'));
if(get_field('weekend_4_start')) $daterange .= '<br /><strong>Wk 4:</strong> '.combineDates(get_field('weekend_4_start'),get_field('weekend_4_end'));
//if(!get_field('weekend_4_start') && (get_field('seminar_category') == 'LifeWorks')) $daterange .='<br /><strong>Wk 4:</strong> TBA';
return $daterange;
}
}
$semdates = processDates();
据我所知,该函数不期望将任何参数传递给它。
感谢您在正确的方向上提供任何帮助或推动。
这是它生成的错误消息: PHP致命错误:未捕获ArgumentCountError:函数processDates()的参数太少,0在第123行传入/page-SeminarCalendar.php,在/page-SeminarCalendar.php:69中预期正好3