简体   繁体   中英

Fatal error: Cannot redeclare __autoload()

Fatal error: Cannot redeclare __autoload() (previously declared in C:\\xampp\\htdocs\\app\\bootstrap.php:25) in C:\\xampp\\htdocs\\app\\bootstrap.php on line 28

This is the error my bootstrap file throws, and it's a pretty hard error to solve. I did the basic stuff, check if there aren't 2 classes with the same name etc. but that wasn't the case. So the thing is: Whats Next?

This is the __autoload functions I'm using:

function __autoload($class_name)
{
    include_once(BASEURL . DS . 'classes' . DS . 'class.' . strtolower($class_name) . '.php');
}

$db = new Database();
$data = new Data();
$mail = new PHPMailer(true);
$functions = new Functions($db);
$users = new users($db, $data, $mail, $functions);

My Questions:

  • How is it possible to solve this error? Especially since there isn't a class which is defined double, and there aren't 2 classes with the same name.

  • Is there a way to prevent this error for the next time?

I would like to draw your attention to the fact that I'm a new Stackoverflow user, and I did my very best while asking this question. If you see any improvement that could help me asking my next questions in a way that all Stackoverflow users would agree, please tell me since there's always room for improvement.

I solved it, thanks to the comments on the OP.

The thing was, I was making use of an iframe to load specific content, which also included the bootstrap.php file. Thats why it shows that's redeclared twice.

Still thanks for all the comments guys.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM