Jump to content

[SOLVED] PHP Cannot redeclare class


zipp

Recommended Posts

I have 6 files, and two of them do not seem to want to play well. I keep getting a "Cannot redeclare class" error.

 

**  edit  **

I know its these 2 files, because when i comment out the include for login.php, the error goes away.

**end edit**

 

The full error:

Fatal error: Cannot redeclare class Base in \core\Base.php on line 7

 

Base.php

<?php
/**
* Base.php is the base class for all functions.
* 
*/

class Base {

function __construct() {

	include("Admin.php");
	include("Feed.php");
	include("Login.php");
	include("Session.php");
	include("SQLManager.php");
	include("Twitter.php");

}

function __destruct() {
}

} 
?>

 

Login.php

<?php
/**
* Login.php is the class for all Application login functions.
* 
*/

class Login extends Base {

function __construct() {
}

function Login() {
}

function Logout() {
}

function __destruct() {
}

} 
?>

 

All of the files that are included in the Base __construct, extend Base.

 

Anyone have any ideas?

Link to comment
Share on other sites

Still, the idea of every class extending a 'Base' like that is ridiculous. How can the classes (assuming these are the names of the classes included) Session, SQLManager and Twitter share the same parent? There names don't suggest that they would be related at all.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.