Re: must I use var
| From: | Raymond Lilleodegard | Date: | Sun, 17 Feb 2002 22:20:46 +0000 |
| Subject: | Re: must I use var | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-85118@lists.php.net to get a copy of this message | ||
Hi Peter!
The "var" $somevariable means that the variable is defined. You only need to
use var in classes. So if you only write ordinary scrpits, you dont need to
use it.
Regards Raymond
"Peter J. Schoenster" <php@errorcode.com> wrote in message
news:3C6FC20B.3856.610F245@localhost...
> HI,
>
> I was reading the docs and I see this:
>
> > /* This is how it should be done. */
> > class Cart
> > {
> > var $todays_date;
> > var $name;
> > var $owner;
> > var $items;
> >
> > function Cart()
> > {
> > $this->todays_date = date("Y-m-d");
> > $this->name = $GLOBALS['firstname'];
> > /* etc. . . */
> > }
>
> I don't see the point in doing
>
> var $todays_date;
>
> and
>
> $this->todays_date = date("Y-m-d");
>
> The latter works without the need for the "var". Why should i use
> "var"?
>
> Thanks,
>
> Peter
> http://www.readbrazil.com/
> Answering Your Questions About Brazil