我使用 phpMailer 来处理从网站发送的邮件。今天早上突然收到如下消息:
致命错误:不再支持 __autoload(),请在第 45 行的 C:\xampp\htdocs\webapp\PHPMailerAutoload.php 中改用 spl_autoload_register()
我在服务器上运行 PHP 8.0.0
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);
}
}
原文由 mAhmedSiddiki 发布,翻译遵循 CC BY-SA 4.0 许可协议
您使用的是非常旧的 PHPMailer 版本——该代码已经 3 年没有出现在 PHPMailer 中了。从 PHPMailer 6.2.0 开始正式支持 PHP 8.0,请务必阅读升级指南。