I’m trying to use spl_autoload_register to use an instantiated object as the autoloader. Is it possible? I have seen in a couple of places where people have used a classes static function as the autoloader, but not an object.
Example:
class loadFile{
function loadObject($object){
//load object here
}
}
$loadmefiles = new loadFile();
//use $loadmefiles->loadObject() as autoloader
spl_autoload_register();
$goat = new Animal('goat');
Hopefully you understand what I am getting at.
This is done by passing an array to
spl_autoload_register: the first element being the object, the second being the name of the method as a string:From the callable documentation: