Mschumi Posted March 20, 2010 Share Posted March 20, 2010 Hey there, well I've been off coding for a good year at least and I've forgotten / lost something out of my brain. Anyway, in PHP4 I use to be able to do this... function new_class($cName, $file) { require $file.'.php'; $this->$cName = new $cName(); $this->$cName->cp = $this; } That would be in my master class, then inside the new class I just made, I would be able to access other classes like so... $this->cp->somClass->aFunction However it seems the below line doesn't do anything $this->$cName->cp = $this; Solution? Link to comment https://forums.phpfreaks.com/topic/195952-accessing-parent/ Share on other sites More sharing options...
Mschumi Posted March 20, 2010 Author Share Posted March 20, 2010 I've found the problem. The parent class was being called via __construct__ in the child class, hence before $this->$cName->cp = $this; Thanks anyway. Link to comment https://forums.phpfreaks.com/topic/195952-accessing-parent/#findComment-1029279 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.