I am vague at understanding the include paths and how they are written out, I know how to set them within the ini
file and how to functionally do it set_include_path
just not how to get it to be exact each time no matter what.
So I have an admin autoload file that I include in all my headers to register the spl_autoload_register
function. I just keep getting errors in my error_log
file. It says that
PHP Fatal error: Class 'Configurate' not found in
/home/~username~/public_html/testing_ini.php on line 5
So what I am looking for is how can I set the include path to always be the directory before the public_html
directory no matter where I am?
I've tried setting the include path to such
.:/opt/alt/php5/usr/share/pear:/opt/alt/php5/usr/share/phphome/~username~/classes/Configurate.php
But I still get the error. Any help and some tips to understanding this entire thing? I suck at relative
paths
As per requested spl_autoload_register
function
<?php
$ini = parse_ini_file("configurations.ini",true);
foreach($ini as $section) {
foreach($section as $key=>$value ) {
define("__".strtoupper($key)."__",$value);
}
}
//if(__USERNAME__ == null) {
// header("Location: /setup.php?step=1");
// exit();
//}
spl_autoload_register(function($class) {
try {
if(!file_exists("../classes/{$class}.php")){
throw new Exception("/classes/{$class}.php does not exist error on line ". __LINE__." in file ". realpath(__FILE__));
} else
require_once "../classes/{$class}.php";
} catch (Exception $ex) {
echo $ex->getMessage()."<br>";
echo $ex->getCode();
}
});