This is boggling my mind. I wrote a quick auto-loader and it appears to work like it is supposed to, except that it keeps changing the argument $class from the class name to "self". Here is the code (followed by further information on what I've tried):
public static function load($class) {
$found = false;
foreach (self::$includePaths as $path) {
if (file_exists(ROOT . $path . DS . $class . '.php')) {
require_once(ROOT . $path . DS . $class . '.php');
$found = true;
break;
}
}
if (!$found) {
die($class . ' not found');
}
}
Okay so basically, if a class can't be loaded I want to know what class it was so I die with a message containing the contents of $class. If I write "echo $class;" before the red if block it works fine and echos the class name. However, for some reason if I try to echo $class within that if block or after it inside of the method it changes the contents of $class to "self". var_dump($class) returns string(4) "self". Is there a reason it is randomly changing the contents of my $class variable!?!? I've tried various other methods including unsetting the path when the class file is found followed by an if (isset($path)) { die($class . ' not found'); } but still no dice, it changes the contents of $class to self. I've been banging my head off this problem for hours now with no success, so if anyone has any feedback or suggestions at all I would love you forever.
Thanks!