jambroo Posted December 7, 2007 Share Posted December 7, 2007 Hello, Im writing some code in PHP involving multiple classes and i need them to talk to eachother, however if i declare one and refer to it in one declared later i get an error. Im assuming the scope of the object must not reach inside that class. So i was wondering what the most elegant way would be to refer to a class declared outside of the one that is being used. I have thought about passing the reference in the constructor but that looks a tad messy. Thanks, -Jamie Link to comment https://forums.phpfreaks.com/topic/80546-php-class-interaction/ Share on other sites More sharing options...
teng84 Posted December 7, 2007 Share Posted December 7, 2007 whats the error? Link to comment https://forums.phpfreaks.com/topic/80546-php-class-interaction/#findComment-408399 Share on other sites More sharing options...
jambroo Posted December 7, 2007 Author Share Posted December 7, 2007 Its a fatal error because its trying to reference a method of an variable that isnt an object. "Fatal Error: Call to a member function method() on a non-object... Link to comment https://forums.phpfreaks.com/topic/80546-php-class-interaction/#findComment-408401 Share on other sites More sharing options...
redbullmarky Posted December 7, 2007 Share Posted December 7, 2007 please can you post the code in question. Link to comment https://forums.phpfreaks.com/topic/80546-php-class-interaction/#findComment-408710 Share on other sites More sharing options...
jambroo Posted December 10, 2007 Author Share Posted December 10, 2007 I was going to post code but I found solution: you can reference global variables using $GLOBALS['variable_name']. -jamie Link to comment https://forums.phpfreaks.com/topic/80546-php-class-interaction/#findComment-410596 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.