Re: classes inside classes
| From: | Burhan Khalid | Date: | Wed, 09 Apr 2003 14:26:56 +0000 |
| Subject: | Re: classes inside classes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143086@lists.php.net to get a copy of this message | ||
On Tue, 2003-04-08 at 10:59, Tim wrote:
> i have worked with ASP on windows IIS for a long time now, but have started to use PHP more and
> more.
> there is a feature in ASP that i can't seem to replicate in PHP.
>
> i have a class called Net. in this class i would like to have an other class called FTP. and in
> the class FTP, have a method called
> Get(). so then i could access Net::FTP::Get() for example.
>
> does this exist in PHP or is there a workaround?
I'm sure PHP5 will handle OOP better, however, if there is an immediate
need, something like this would work :
class b { function bar() { echo "bar"; } }
class a {
var $obj;
function init() { $this->obj = new classb(); }
function foo() {
$this->obj->bar();
}
}
The only caveat is that you have to instantiate the object from inside a
function, you can't do var $obj = new classb();
Is this what you were after? I personally love the scope resolution
operator myself -- but that's just the C++ lover in me <grin>
--
Burhan Khalid
phplist[at]meidomus[dot]com
Please add a reply-to: header
in your messages that points
to the mailing list address
so that all mail is properly
archived and viewed.