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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.