note 36341 added to language.oop.constructor
| From: | zzz1 at ukr dot net | Date: | Mon, 06 Oct 2003 13:55:26 +0000 |
| Subject: | note 36341 added to language.oop.constructor | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-57893@lists.php.net to get a copy of this message | ||
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
*/
?>
----
Manual Page -- http://www.php.net/manual/en/language.oop.constructor.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36341
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36341&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36341&report=yes
Search -- http://master.php.net/manage/user-notes.php