Im on php 5.2.x
I have a loader class that looks like so:
class Loader {
static $account_nameClasses = array(
'DB' => '/home/account_name/public_html/includes/php/DB.php',
'Skin' => '/home/account_name/public_html/includes/php/Skin.php',
'API' => '/home/account_name/public_html/api/apiClass.php',
'Search' => '/home/account_name/public_html/includes/php/Search.php',
'User' => '/home/account_name/public_html/includes/php/User.php'
);
static function loader($className) {
$filename = self::$account_nameClasses[$className];
if(file_exists($filename)){
require_once $filename;
}else{
return false;
}
}
}
spl_autoload_register(array(account_name_Loader, 'loader'));
As you can see, I repeat /home/account_name/public_html/includes/php/ over and over.
I want to replace that with a constant (or anything else) so that I can easily change it if I move the location of the app.
I tried this (Any may forms of this), but it just doesn't work
const PHP_CLASSES_ROOT = '/home/account_name/www/';
static $account_nameClasses = array(
'DB' => self::PHP_CLASSES_ROOT.'DB.php',
'Skin' => self::PHP_CLASSES_ROOT.'Skin.php',
'Search' => self::PHP_CLASSES_ROOT.'Search.php',
'User' => self::PHP_CLASSES_ROOT.'User.php'
);
Any ideas?