question regarding subclasses, is this possible to do

From: Date: Mon, 01 Dec 2003 21:30:29 +0000
Subject: question regarding subclasses, is this possible to do
Groups: php.general 
Request: Send a blank email to php-general+get-171499@lists.php.net to get a copy of this message
Hi, i was wondering if the last line of the following code is possible somehow (the second last works perfect) but say i wanted to automatically get the id (or anything else for that particular window) would it be possible? or would i have to include a new function in windows called setID or something like that? ----------------php code----------------------------- <?php class house{ var $windows; function house(){ $this->windows = new windows(); } function getSize(){ return "Big House"; } } class windows{ var $id; function windows($id = "all"){ $this->id = $id; } function showID(){ echo "<br>ID: " . $this->id; } } $test = new house(); echo $test->getSize() . "<br>\n\n"; $test->windows->showID(); $test->windows("Window3")->showID(); ?> -------------------end php code-------------- I could always have $test->windows->setID($id) then display the properties for that current window, but it would be sumpler if i could use $test->windows($id)->showID() and if no var is there, show all...any ideas on how to do this? Thanks heaps Luke

« previous php.general (#171499) next »