Jump to content

Archived

This topic is now archived and is closed to further replies.

fogeytron

Using a class inside another class

Recommended Posts

Hello there,

This is not my exact code, just the general idea.

class.c.inc
------------------
class C
{
.
.
.
}

-------------------
include 'class.c.inc';
class A
{
var $b = new C();
.
.
.
}

error

Parse error: parse error in /Users/jonathan/fogeytron_be/www/DNS/class.zonefile.inc on line 9

Where line 9 is var $b = new C();.

I have not seen any code that attempts this. I have done it in C++. It seems rather basic. So I think I am calling it incorrectly.

Please help?

Share this post


Link to post
Share on other sites
You need to assign it within the construct. (I assume your using php4)
[code]
include 'class.c.inc';
class A
{
var $b;

function A() {
  $this->b = new C();
}
.
.
.
}
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.