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"???????????? 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? 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 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] 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! 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
Archived
This topic is now archived and is closed to further replies.