Bluehost.com Web Hosting $6.95

question regarding subclasses, is this possible to do

This is a discussion on question regarding subclasses, is this possible to do within the PHP General forums, part of the PHP Programming Forums category; Hi, i was wondering if the last line of the following code is possible somehow (the second last works perfect) ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-01-2003
Luke
 
Posts: n/a
Default question regarding subclasses, is this possible to do

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
Reply With Quote
  #2 (permalink)  
Old 12-01-2003
Curt Zirzow
 
Posts: n/a
Default Re: [PHP] question regarding subclasses, is this possible to do

* Thus wrote Luke (webmaster@build3d.com.au):
>
> $test->windows->showID();
> $test->windows("Window3")->showID();
> ?>
> -------------------end php code--------------


You might want to read:
http://php.net/oop


Curt
--
If eval() is the answer, you're almost certainly asking the
wrong question. -- Rasmus Lerdorf, BDFL of PHP
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 05:15 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0