Well, I know it declares a variable in a class. But why is it
necessary?
Any variable declared in a class will be part of that class.
Does 'var' serve some other purpose?
1. initialization
var $foo='init';
if you do initialitation in the constructor only, you cannot be sure that the vars will be initialized in all cases, if it´s a parent class only the constructor of the deepest subclass will be executed automatically, if present
2. list of properties
you can put there all object-vars you´ll use in that class too, to simplify code exchange with other programmers and to avoid duplicate var names...
3. <guess> I think it´ll be faster to initialize them using var, instead of initializing elsewhere [that part of the class can be interpreted once unlike it´s methods] </guess>
4. if static access to properties would be available, you could access the properties without instanciating ;)
I´m sure there are more reasons to use var, but these are the most important I know of...
regards
--
o----------0-¬---------O-·---¬----o---®-----o o O ° .
| http://www.kiffen.de | pRoteçt y0ur bRaín |0 O ° ¤ °
·
0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ °
o © ° . ·
| psychedelic experience | gott@kiffen.de | O ° o °
o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ ·