To make a long story short, I'm taking input from the command line, and using that input to make a decision, and then load another class based on that decision. For some reason it keeps exiting, without loading the class and without error:
This is the first part of the code:
Code: Select all
$xml = simplexml_load_file("Config.xml");
$em = new ExtensionManager();
$extension = $em->ScanExtensions((string)$xml->default_extension);
echo("This text will not appear");
//# This seems to call, but it exits immediately afterwards and it SHOULDN'T because inside is an infinite loop.
$e = new $extension();
Code: Select all
public function ScanExtensions($defaultExtension) {
Logger::log(__CLASS__, "Listing valid extensions...");
if ($handle = opendir('./Extensions')) {
echo("*********************************************\n");
$i = 1;
$list = array();
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_dir("./Extensions/$file")) {
if(file_exists("./Extensions/$file/$file.php")) {
echo("[$i]\t$file\n");
$list[] = $file;
$i++;
}
}
}
closedir($handle);
echo("*********************************************\n");
}
$out = fopen("php://stdout", "w");
$in = fopen("php://stdin", "r");
fwrite($out, "Which project should I launch? [blank = $defaultExtension]: ");
$ProjectName = trim(fgets($in));
fclose($out);
fclose($in);
if($ProjectName > 0) {
Logger::log(__CLASS__, "Loading extension ".$list[$ProjectName-1].".");
//sleep(3);
$ext = $list[$ProjectName-1];
}else {
Logger::log(__CLASS__, "Loading default extension $defaultExtension.");
//sleep(3);
$ext = $defaultExtension;
}
return $ext;
}
It just simply exits without any errors at all! I have error_reporting set to E_ALL. There is nothing wrong with the class file that gets called, because I can launch it just fine by commenting out the call to the ScanExtension method, and typing $e = new Example() in the first block of outlined code above.
I'm not sure what's going on. I have tried taking the ScanExtension code from the method and just placing it beneath the first code block outlined above, and I get the same results.
Any help at all would be greatly appreciated!