note 92924 added to language.oop5.decon

From: Date: Fri, 14 Aug 2009 20:53:35 +0000
Subject: note 92924 added to language.oop5.decon
Groups: php.notes 
Request: Send a blank email to php-notes+get-159497@lists.php.net to get a copy of this message
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(); ?> ---- Server IP: 209.41.74.194 Probable Submitter: 96.50.79.253 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.decon.php Edit -- https://master.php.net/note/edit/92924 Del: integrated -- https://master.php.net/note/delete/92924/integrated Del: useless -- https://master.php.net/note/delete/92924/useless Del: bad code -- https://master.php.net/note/delete/92924/bad+code Del: spam -- https://master.php.net/note/delete/92924/spam Del: non-english -- https://master.php.net/note/delete/92924/non-english Del: in docs -- https://master.php.net/note/delete/92924/in+docs Del: other reasons-- https://master.php.net/note/delete/92924 Reject -- https://master.php.net/note/reject/92924 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#159497) next »