parino_esquilado Posted January 24, 2011 Share Posted January 24, 2011 Take the following example: <?php class a { var $things; public function __construct($stuff) { $this->things = $stuff; } } class b { var $morethings; $this->morethings = "something"; } $c = new a(new b); echo $c->things->__PARENT__; ?> The line "echo $c->things->__PARENT__;" (as you can probably imagine) does not work. How would I output what the 'b' object is stored in ('a')? Quote Link to comment https://forums.phpfreaks.com/topic/225476-classes-help/ Share on other sites More sharing options...
trq Posted January 24, 2011 Share Posted January 24, 2011 echo $c->things->morethings; As a side note, a & b are in no way related. Quote Link to comment https://forums.phpfreaks.com/topic/225476-classes-help/#findComment-1164307 Share on other sites More sharing options...
parino_esquilado Posted January 24, 2011 Author Share Posted January 24, 2011 <?php class a { var $things; public function __construct($stuff) { $this->things = new b; } } class b { var $morethings; $this->morethings = "something"; } $c = new a(); echo $c->things->__PARENT__; ?> Are a and b related now? Quote Link to comment https://forums.phpfreaks.com/topic/225476-classes-help/#findComment-1164351 Share on other sites More sharing options...
trq Posted January 24, 2011 Share Posted January 24, 2011 No. a just depends on b. See http://php.net/manual/en/language.oop5.inheritance.php Quote Link to comment https://forums.phpfreaks.com/topic/225476-classes-help/#findComment-1164722 Share on other sites More sharing options...
parino_esquilado Posted January 25, 2011 Author Share Posted January 25, 2011 thanks. =) Quote Link to comment https://forums.phpfreaks.com/topic/225476-classes-help/#findComment-1164894 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.