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? Quote 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] Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.