DateTime方法链接问题

Ric*_*nop 2 php

这有效:

$aWeekAfterDate = new DateTime(); 
$aWeekAfterDate->modify('+1 week');
$aWeekAfterDate->format('d.m.Y');
Run Code Online (Sandbox Code Playgroud)

但是这个:

$aWeekAfterDate = new DateTime(); 
$aWeekAfterDate->modify('+1 week')->format('d.m.Y');
Run Code Online (Sandbox Code Playgroud)

给我这个错误:

致命错误:在......在线的非对象上调用成员函数format()...

致命错误(关闭):在......在线的非对象上调用成员函数format()...

我在文档中查找了DateTime :: modify方法,其返回值如下:

返回方法链接的DateTime对象或失败时返回FALSE.

为什么方法链不起作用?

我使用的是PHP 5.2.6版.

Mar*_*ker 7

更新日志

Version   Description 
5.3.0     Changed the return value on success from NULL to DateTime. 
Run Code Online (Sandbox Code Playgroud)

因此,仅在PHP 5.3.0中引入了返回DateTime对象以进行链接