Jump to content

Creating new class by variable not working


kartul

Recommended Posts

Hey all :)

 

Creating new class by variable should work, atleast in php manual says so but why it isn't working here? Using php 5.3.7.

Error it says is can't find class called 'test'. It is there and if I replace $class with test the it works. And $class is equal to test.

 

function load_class($path, $class)
	{
		$class = strtolower($class);
		if( isset( $this->loaded_classes[$class] ) )
		{
			return $this->loaded_classes[$class];
		}
		else
		{

			#include $path . 'test.php';
			#include './' . $class . '.php';
			#debug_backtrace($class);
			#$s = new $class;
			include $path . $class . '.php';
			#eval('self::$loaded_classes['.$class.'] = new '.strtolower($class).'();');
			$this->loaded_classes[$class] = new $class();
			echo 'ok';
			return $this->loaded_classes[$class];
		}
	}

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.