From 057c7c4621ec197247ad97b779ba63ee544baf14 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Fri, 6 Jun 2008 06:43:52 +0000 Subject: [PATCH] Autoloader: Added backwards-compatibility for PHP versions without spl_autoload_register. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@611 44740490-163a-0410-bde0-09ae8108e29a --- lib/_autoload.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/_autoload.php b/lib/_autoload.php index b05ee4569..8ae891b9e 100644 --- a/lib/_autoload.php +++ b/lib/_autoload.php @@ -33,7 +33,24 @@ function SimpleSAML_autoload($className) { } } -/* Register autload function for simpleSAMLphp. */ -spl_autoload_register('SimpleSAML_autoload'); +/* Register autoload function for simpleSAMLphp. */ +if(function_exists('spl_autoload_register')) { + /* Use the spl_autoload_register function if it is available. It should be available + * for PHP versions >= 5.1.2. + */ + spl_autoload_register('SimpleSAML_autoload'); +} else { + + /* spl_autoload_register is unavailable - let us hope that no one else uses the __autoload function. */ + + /** + * Autoload function for those who don't have spl_autoload_register. + * + * @param $className The name of the requested class. + */ + function __autoload($className) { + SimpleSAML_autoload($className); + } +} ?> \ No newline at end of file -- GitLab