【发布时间】:2011-03-31 09:06:56
【问题描述】:
这行得通:
$aWeekAfterDate = new DateTime();
$aWeekAfterDate->modify('+1 week');
$aWeekAfterDate->format('d.m.Y');
但是这个:
$aWeekAfterDate = new DateTime();
$aWeekAfterDate->modify('+1 week')->format('d.m.Y');
给我这个错误:
致命错误:调用成员函数 format() 在...中的非对象上 线...
致命错误(关闭):调用 成员函数 format() 上 non-object in ...在线...
我在文档中查找了DateTime::modify方法,它的返回值是这样的:
返回方法的 DateTime 对象 失败时链接或 FALSE。
为什么方法链不起作用?
我使用的是 PHP 5.2.6 版。
【问题讨论】:
标签: php