PHP代码 - 不知道它是否有所作为

i have the following code snippet, in an appliation working with Zend Framework. I know what Zend Date does.. thats not the problem.

But the coder simply calls "$date" , and i dont know if this does something?

         $date = new Zend_Date(time());
         $date->addDay(1);
         $date; 
         // save date, or do something else
         ...

I can't imagine a situation where simply stating a variable, whether it be an object, string, or otherwise, would perform some kind of action. It might just be a mistake.

As far as I can tell, it does nothing except using up some CPU cycles.

Maybe it had other use before, like echo $date;. Just writing a variable does absolutely nothing.

It adds a day to $date. Where is the confusion? The 3rd line does nothing.

@ArneRie please check this => addDay :Adds days to the existing date object.

The day can be a number or a string. Adding days lower then 0 or greater than the number of this months days will result in adding or subtracting the relevant month. If a localized dayname is given it will be parsed with the default locale or the optional set locale.

return: Provides fluid interface throws: Zend_Date_Exception access: public

Zend_Date addDay ( $day, [string|Zend_Locale $locale = null],

  • string|integer|array|Zend_Date $month)
  • string|integer|array|Zend_Date $month: Day to add
  • string|Zend_Locale $locale: OPTIONAL Locale for parsing input $day