Hi, I have this class that have a function to load other classes and create instances.
if you used this class like this:
$test = new test();
$test->load("email");
it works perfectly as expected but when using session_start();
$test = new test();
session_start();
$test->load("email");
an error is created and nothing else is there: PHP Fatal error: Call to a member function load() on a non-object in bla bla bla
the class used with session_start:
<?php
class test
{
function load($class){
static $objects = array();
if (isset($objects[$class]))
{
return $objects[$class];
}
require('libraries/'.$class.'.php');
$name = 'ext_'.$class;
$objects[$class] =& new $name();
$this->$class = $objects[$class];
return $objects[$class];
}
}
$test = new test();
session_start();
$test->load("email");
?>
and here is libraries/email.php:
<?php
class ext_email
{
function ext_email(){
echo "email is working";
}
}
?>
can you please advice what is wrong with this? a way to improve the load function? this thing works on some installations of apache and fail to work on others. depending on some configs that I don't know what exactly is it..
I want to be able to do the following: $test = new test();
session_start();
$test->load("email");
thanks a lot in advance