note 36341 deleted from language.oop.constructor by didou

From: Date: Mon, 06 Oct 2003 14:08:17 +0000
Subject: note 36341 deleted from language.oop.constructor by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-57894@lists.php.net to get a copy of this message
Note Submitter: zzz1@ukr.net ---- Be aware to forget to initialize some vars in constructor regardless of initializing them in the class; <?php class CC{ var $test='1234567'; /*will be set to nothing after constructor is executed;*/ function CC(){ $this->mam(); } function mam(){ print $this->$test." if you see\n"; } } $ma=new CC; /*will produse if you see */ ?> To make it work you need this: <?php class CC{ var $test; /*will be initialized in constructor*/ function CC(){ $this->$text='1234567'; ##initialization; $this->mam(); } function mam(){ print $this->$test." if you see\n"; } } $ma=new CC; /*will produse 1234567 if you see */ ?>

« previous php.notes (#57894) next »