fogeytron Posted April 10, 2006 Share Posted April 10, 2006 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(); . . .}errorParse error: parse error in /Users/jonathan/fogeytron_be/www/DNS/class.zonefile.inc on line 9Where 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? Link to comment https://forums.phpfreaks.com/topic/6990-using-a-class-inside-another-class/ Share on other sites More sharing options...
trq Posted April 10, 2006 Share Posted April 10, 2006 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] Link to comment https://forums.phpfreaks.com/topic/6990-using-a-class-inside-another-class/#findComment-25497 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.