PHP Fatal error: Cannot redeclare PHPMailerAutoload() (previously declared in /home2/epsilonbr/ticket/PHPMailer/PHPMailerAutoload.php:24) in /home2/epsilonbr/ticket/PHPMailer/PHPMailerAutoload.php on line 24
Hello guys this was working till yesterday, suddenly today someone tried to send me a ticket and I received this error.
I am using the default mailer autoload I haven’t changed anything
function PHPMailerAutoload($classname)
{
//Can't use __DIR__ as it's only in PHP 5.3+
$filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
if (is_readable($filename)) {
require $filename;
}
}
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
//SPL autoloading was introduced in PHP 5.1.2
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
spl_autoload_register('PHPMailerAutoload', true, true);
} else {
spl_autoload_register('PHPMailerAutoload');
}
} else {
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
function __autoload($classname)
{
PHPMailerAutoload($classname);
}
}
Any ideas on why this is happening? Line 24 is the function PHPMailerAutoload($classname)
2
Answers
The solution was really easy and as @CBroe said.
I had added the
require 'PHPMailer/PHPMailerAutoload.php';
twice in the code, once inside the header.php and the second time was inside the something_in_the_body.php file because I forgot that I had added that inside the header.