-
Notifications
You must be signed in to change notification settings - Fork 1
/
taasc_autoload.php
49 lines (44 loc) · 1.54 KB
/
taasc_autoload.php
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* An autoload function for software from The Analysis and Solutions Company
*
* NOTE: If your system already has an autoloader, feel free to integrate the
* concepts in this autoload function into yours and then comment out the
* spl_autoload_register() call. If you do so and also use our PHPUnit tests,
* don't forget to edit the bootstrap.ini file to include your autoloader.
*
* @package SQLSolution
* @author Daniel Convissor <[email protected]>
* @copyright The Analysis and Solutions Company, 2001-2011
* @license http://www.analysisandsolutions.com/software/license.htm Simple Public License
* @link http://www.analysisandsolutions.com/software/sql/sql.htm
*/
if (!defined('TAASC_DIR_INCLUDE')) {
/**
* Set the include path to the current directory
*
* Using dirname(__FILE__) because __DIR__ introduced in PHP 5.3.
*/
define('TAASC_DIR_INCLUDE', dirname(__FILE__));
}
/**
* An autoload function for software from The Analysis and Solutions Company
*
* Uses the PEAR naming convention of "_" in class names becoming "/".
*
* Checks the current directory and subdirectories thereof first,
* then tries via the include_path.
*
* @return void
*/
function taasc_autoload_example($class) {
$class = str_replace('_', '/', $class);
if (file_exists(TAASC_DIR_INCLUDE . '/' . $class . '.php')) {
// Local file, get it.
require TAASC_DIR_INCLUDE . '/' . $class . '.php';
} else {
// File doesn't exist locally. Use include path.
require $class . '.php';
}
}
spl_autoload_register('taasc_autoload_example');