views:

83

answers:

6

Hi

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
         ...
+3  A: 

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.

Mike B
`I can't imagine a situation where simply stating a variable, [...] would perform some kind of action.`Not in PHP, at least :)
nico
+2  A: 

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

Techpriester
+1 in other words, remove it! No point wasting CPU, and no point confusing any more future developers looking at it.
alex
A: 

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

Bogdan Constantinescu
+1  A: 

Probably a typo. Since it's already been initialized, and it's not being set or used in that statement I'm not sure how this does anything specific.

BoltClock
A: 

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

balupton
+1  A: 

@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
Ankur Mukherjee