严格标准:非静态方法DateUtility::subtractDaysFromDate()不应该静态调用,假设$this来自不兼容的上下文/home/zumpu/public_html/cats/cats-0.8.0/modules/activity/ActivityUI.php第449行
严格标准:非静态方法DateUtility::addDaysToDate()不应该静态调用,假设$this来自不兼容的上下文/home/zumpu/public_html/cats/cats-0.8.0/lib/DateUtility.php中的285行
public function subtractDaysFromDate($startDate, $daysToSubtract)
{
return self::addDaysToDate($startDate, ($daysToSubtract * -1)); //285 line
}
//第一个错误代码行449
private function makeQuickLinkURL($dayOfWeek)
{
/* PHP's date('w') uses 0-6 to represent weekdays, but the CATS weekday
* constants use 1-7.
*/
$dayOfWeek--;
$currentDate = time();
$daysDifference = date('w', $currentDate) - $dayOfWeek;
$linkDate = DateUtility::subtractDaysFromDate($currentDate, $daysDifference);//**line 449**
switch ($daysDifference)
{
case -1:
$dayString = '<span style="display: inline;">Tomorrow</span>';
break;
case 0:
$dayString = '<span style="color: #ff6600; display: inline;">Today</span>';
break;
case 1:
$dayString = '<span style="display: inline;">Yesterday</span>';
break;
default:
$dayString = date('l', $linkDate);
break;
}
$month = date('n', $linkDate);
$day = date('j', $linkDate);
$year = date('Y', $linkDate);
帮助我解决这个错误
你的问题不止一个:
在你的实例方法subtractDaysFromDate()
中,你静态地调用addDaysToDate()
,这也是一个实例方法。然后你需要用$this->
来调用它。但是它会产生致命的错误,原因很简单:
$this
指的是当前实例,但是您没有:
$linkDate = DateUtility::subtractDaysFromDate($currentDate, $daysDifference);
因为subtractDaysFromDate()
是静态调用的,所以没有实例。
您应该决定这些方法是否是静态的并在它们上添加关键字static
,或者通过类的实例调用它们。
在这种情况下,DateUtility
类需要实例化。
$dateUtility = new DateUtility();
$linkDate = $dateUtility->subtractDaysFromDate($currentDate, $daysDifference);
然后public function subtractDaysFromDate($startDate, $daysToSubtract)
{
return $this->addDaysToDate($startDate, ($daysToSubtract * -1)); //285 line
}