Provide fallback autoloading for old PHP versions, see #113
This commit is contained in:
parent
41415a821f
commit
e26e978d78
|
|
@ -30,4 +30,13 @@ function PHPMailerAutoload($classname)
|
|||
}
|
||||
}
|
||||
|
||||
spl_autoload_register('PHPMailerAutoload', true, true);
|
||||
if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
|
||||
//SPL autoloading was introduced in PHP 5.1.2
|
||||
spl_autoload_register('PHPMailerAutoload', true, true);
|
||||
} else {
|
||||
//Fall back to traditional autoload for old PHP versions
|
||||
function __autoload($classname)
|
||||
{
|
||||
PHPMailerAutoload($classname);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -571,7 +571,7 @@ class PHPMailer
|
|||
{
|
||||
$this->exceptions = ($exceptions == true);
|
||||
//Make sure our autoloader is loaded
|
||||
if (!spl_autoload_functions() || !in_array('PHPMailerAutoload', spl_autoload_functions())) {
|
||||
if (version_compare(PHP_VERSION, '5.1.2', '>=') and !spl_autoload_functions() || !in_array('PHPMailerAutoload', spl_autoload_functions())) {
|
||||
require 'PHPMailerAutoload.php';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue