Jump to content

Fatal error: Cannot redeclare class


ChrisMartino

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.