Jump to content

autloader class constuctor (not loading)


Destramic

Recommended Posts

hey guys im having a problem with my class it sees the constructor isnt loading and this line isnt executed

 

spl_autoload_register(array($this, 'load_class'));

 

i dont see why not if anyone can help please

 

<?php

class Autoloader
{	
private static $_declared_classes = array();
private static $_ignore_files     = array();

public function __construct()
{ 
	spl_autoload_register(array($this, 'load_class'));
}

public static function load_class($class_name)
{	
    $class_name = ucwords($class_name);
	$file       = self::get_class_path($class_name);

	try
	{	
		if (!class_exists($class_name, FALSE))
		{
			if (file_exists($file))
			{
				require_once $file;
				self::$_declared_classes[] = $class_name;
			}
			else
			{
				throw new Exception(sprintf("Class '%s' not found.<br />\n", $class_name));
			}
		}
	}
	catch (Exception $e)
	{
		echo $e->getMessage();	
	}
}	

private static function get_class_path($class_name)
{
	global $classes;

	if (array_key_exists($class_name, $classes))
	{
		return ROOT . DS . $classes[$class_name];
	}
}

public static function declared_classes()
{
	echo "<pre>";
	print_r(self::$_declared_classes);
	echo "</pre>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/234190-autloader-class-constuctor-not-loading/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.