ChrisMartino Posted July 24, 2010 Share Posted July 24, 2010 Hello there, Thank you for taking the time to read this thread, so here is my problem, when I initiate the core class for my application I include anything in the directory that the file is in, here is my class: class panel_core { function __construct() { foreach(glob("*.php") as $LoadModule) { $ModuleCount++; // This holds the current amount of modules that loaded. if($LoadModule != "panel_core.php") include $LoadModule; // check where not including the file twice. echo $LoadModule; // for debuging. } } function destroyModuleInstance($Module) { if(class_exists($Module)) { unset($Module); } } function currentModuleCount() { global $ModuleCount; return $ModuleCount; } } Now I have a problem, I think it is including it's self at some point because I get the following error: Fatal error: Cannot redeclare class panel_core in C:\wamp\www\X-HostLTD - Panel\PanelCore\panel_core.php on line 19 Now I don't understand why it would do that since I do a check before in call the include, yet it's still including it's self?, thanks for your time. Link to comment https://forums.phpfreaks.com/topic/208789-fatal-error-cannot-redeclare-class/ Share on other sites More sharing options...
Mchl Posted July 24, 2010 Share Posted July 24, 2010 Try using include_once instead. Link to comment https://forums.phpfreaks.com/topic/208789-fatal-error-cannot-redeclare-class/#findComment-1090749 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.