Cardale Posted January 20, 2008 Share Posted January 20, 2008 In my class I wanted to load files through my class so I could keep track of how many files are loaded, but I'm having some problems. function LOAD_FILE($root, $subdir, $file){ include($locate[$root].$locate[$subdir].$locate[$file]); $this->counter++; } Everything works fine untill I try to include a file thats using a "object" from a class. So the object can't be found or is not valid. Quote Link to comment https://forums.phpfreaks.com/topic/86862-class-function-need-help/ Share on other sites More sharing options...
trq Posted January 20, 2008 Share Posted January 20, 2008 The $locate array is not defined anywhere within that method. Quote Link to comment https://forums.phpfreaks.com/topic/86862-class-function-need-help/#findComment-444010 Share on other sites More sharing options...
trq Posted January 20, 2008 Share Posted January 20, 2008 Also, note that including a file within a function meens that any variable/object or function declared within that file will only be available within that function. Quote Link to comment https://forums.phpfreaks.com/topic/86862-class-function-need-help/#findComment-444012 Share on other sites More sharing options...
Cardale Posted January 20, 2008 Author Share Posted January 20, 2008 So even if I include a file that has all the required variables previously before this function is called it doesn't matter? Quote Link to comment https://forums.phpfreaks.com/topic/86862-class-function-need-help/#findComment-444066 Share on other sites More sharing options...
KrisNz Posted January 20, 2008 Share Posted January 20, 2008 If all you want to know is how many files are included then use the get_included_files() function. Quote Link to comment https://forums.phpfreaks.com/topic/86862-class-function-need-help/#findComment-444078 Share on other sites More sharing options...
Cardale Posted January 21, 2008 Author Share Posted January 21, 2008 I guess that will work, but it lacks control for other things I wanted to do. Thanks though. Quote Link to comment https://forums.phpfreaks.com/topic/86862-class-function-need-help/#findComment-445315 Share on other sites More sharing options...
Cardale Posted January 21, 2008 Author Share Posted January 21, 2008 I wanted to have more control over what is loaded into the system. You know if its not in my list of files array then don't load it. Check if the file is loadable alone blah blah. Quote Link to comment https://forums.phpfreaks.com/topic/86862-class-function-need-help/#findComment-445325 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.