Re: What is 'var'

From: Date: Thu, 06 Jul 2000 01:43:02 +0000
Subject: Re: What is 'var'
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-23649@lists.php.net to get a copy of this message
I think it is a really great thing. It forces the programmer to be explicit... class foo { var $bar = "bar"; function foo() { $some_locally_scoped_var = 15; } } It is much easier to read /really big/ class files if all vars global to the class are declared var. On Wed, 5 Jul 2000, jalal wrote the following to PHP Development and...: > On Wed, 05 Jul 2000 00:59:01 +0200, waldschrott wrote: > > > > 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'; > > Hmm, but my point was that I could do that without the word 'var'. > > The word 'var' seems to have no reason for its existence, for instance, > this should work (but doesn't). > class foo { > $foo_var = 0; > } > > Semantically, $foo_var is a class variable because its definition is in > a class. > > Ah well, one of the mysteries of PHP. > > - jalal - > > > >

« previous php.dev (#23649) next »