chipk1 Posted November 30, 2006 Share Posted November 30, 2006 This doesn't seem to work? What am I doing wrong?------------------------------------------------------------------class A{ var $data; function A() { $this->data = "information to be displayed"; }}class B{ var $a; function B() { $a = new A(); }}$c = new B();echo $c->a->data;------------------------------------------------It does not echo "information to be displayed"???????????? Quote Link to comment https://forums.phpfreaks.com/topic/29023-return-a-class-pbject-from-within-another-class/ Share on other sites More sharing options...
chipk1 Posted November 30, 2006 Author Share Posted November 30, 2006 No one knows the solution to this? I really need help to move on with my project. Plz plz plz? Quote Link to comment https://forums.phpfreaks.com/topic/29023-return-a-class-pbject-from-within-another-class/#findComment-133021 Share on other sites More sharing options...
Zane Posted November 30, 2006 Share Posted November 30, 2006 because in class B your defining $ainstead of $this->a Quote Link to comment https://forums.phpfreaks.com/topic/29023-return-a-class-pbject-from-within-another-class/#findComment-133029 Share on other sites More sharing options...
trq Posted November 30, 2006 Share Posted November 30, 2006 [code=php:0]class A{ function A() { echo "information to be displayed"; }}class B{ var $a; function B() { $this->a = new A(); }}$c = new B();[/code] Quote Link to comment https://forums.phpfreaks.com/topic/29023-return-a-class-pbject-from-within-another-class/#findComment-133031 Share on other sites More sharing options...
chipk1 Posted November 30, 2006 Author Share Posted November 30, 2006 Duh! Sometimes those extra sets of eyes are valuable. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/29023-return-a-class-pbject-from-within-another-class/#findComment-133037 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.