Hello sam1600,

Wednesday, January 10, 2001, 6:42:58 AM, you wrote:

sic> What in the world is reason for declaring the following in the class?:
sic> var $somevar;
sic> I see no reason, and no differences if I don't declare: var $somevar;

Classes are intended to be structured data storage. You should define
a structure of the class before using the class.
You can set the value of the $somevar anytime later, when using an
object of class a.
$d->somevar = true;
and the next call to $d->b() will print nothing.
But you won't be able to assign a value to $somevar, if it is not
declared in the class.

sic> Maybe a better question is what will break if I do not declare
sic> my vars in my class definition?

the method b() of the class a will break if you don't declare $somevar
in the class definition. In the string "if (!isset($this->somevar))"
it would throw an error saying that you have no variable named 'somevar' in
you class.


-- 
Best regards,
Max A. Derkachev mailto:[EMAIL PROTECTED]
Symbol-Plus Publishing Ltd.
phone: +7 (812) 324-53-53
http://www.Books.Ru -- All Books of Russia
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to