You are here: How do you declare Vars in PHP? -I know it's not necessary, but I still want to know « PHP « IT news, forums, messages
How do you declare Vars in PHP? -I know it's not necessary, but I still want to know

Posted by Jon M. on 05/05/05 08:06

I just found a place here:

http://us2.php.net/manual/en/language.oop.php

That has this example:

/* This is how it should be done. */
class Cart {
var $todays_date;
var $name;
var $owner;
var $items = array("VCR", "TV");

function Cart() {
$this->todays_date = date("Y-m-d");
$this->name = $GLOBALS['firstname'];
/* etc. . . */
}
}

It appears that they are declaring vars like this:

var $todays_date;


Is this something you can only do inside a class???

-Jon




"Bala Chandar" <mbchandar@gmail.com> wrote in message
news:dc538c3f05050419552489a733@mail.gmail.com...
Hi

On 5/5/05, Jon M. <dsak8330225@yahoo.com> wrote:
> I know in JavaScript, that you declare vars like so:
>
> var = variableName;
>
> So I'm assuming that in PHP you do it like this:
>
> var = $variableName;

I think you can do like this inside a class
var $variableName;

> But there doesn't seem to be a single shred of documentation on PHP.net
> (or
> in ANY book) that covers this. All they say is that it's good practice,
> but

check out http://www.php.net/manual/en/language.variables.php

> not necessary. Then they always skip telling you how.
>
> I always like to declare vars since it helps me keep track of the vars I
> will be using, and I just like to do things right.
>
> So am I right about how you do it? "Yes", "No", example please??

when u use OO concepts, then you can use var. other wise its not neccessary.

>
> -Jon
>


--
bala> balachandar muruganantham
blog> lynx http://chandar.blogspot.com
web> http://www.chennaishopping.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация