note 92924 rejected from language.oop5.decon by danbrown

From: Date: Fri, 14 Aug 2009 20:54:44 +0000
Subject: note 92924 rejected from language.oop5.decon by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159498@lists.php.net to get a copy of this message
Note Submitter: rwallace at trimensionsoftware dot com ---- This should probably be included in the official examples. As with other OO languages, if you'd like to give your class instantiation values as soon as it is created, use the construct function. Ex. <?php class Test { private $value; public function __construct($newValue){ // constructor sets the value passed during instantiation $this->value = $newValue; } public function printValue(){ echo $this->value; } } $test = new Test("hello"); // instantiate class - pass value to constructor $test->printValue(); ?>

« previous php.notes (#159498) next »