object variables declararing

From: Date: Tue, 23 Apr 2002 12:12:18 +0000
Subject: object variables declararing
Groups: php.general 
Request: Send a blank email to php-general+get-94144@lists.php.net to get a copy of this message
hi have look at this code: class test { function test(){ //$this->a = 10; print_r($this); } function test2(){ print_r($this); } } $t=new test(); $t->test2(); what do you see? empty object twice... now uncomment the commented line. now the object got a variable - which is quite unusual, because what`s the reason for declaring them with var keyword except nice looking code? i uderstand on-the-flight creation of local variables, but class variables? hmmmmm... can someone explain the reason of enabling this possibility? rash

« previous php.general (#94144) next »