-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChattyCrowAutoload.php
More file actions
34 lines (33 loc) · 938 Bytes
/
ChattyCrowAutoload.php
File metadata and controls
34 lines (33 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
/**
* ChattyCrow lib autoloader (for tests)
*/
/**
* ChattyCrow SPL autoloader.
* @param string $classname The name of the class to load
*/
function ChattyCrowAutoload($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('ChattyCrowAutoload', true, true);
} else {
spl_autoload_register('ChattyCrowAutoload');
}
} else {
/**
* Fall back to traditional autoload for old PHP versions
* @param string $classname The name of the class to load
*/
function __autoload($classname)
{
ChattyCrowAutoload($classname);
}
}