我使用 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);
}
}
Run Code Online (Sandbox Code Playgroud)