This simple example won't work, gives me:
Fatal error: spl_autoload() [function.spl-autoload]: Class GmailServer could not be loaded.
define('USERNAME', 'username');
define('PASSWORD', 'password');
$SERVER = 'GmailServer';
spl_autoload_extensions(".php");
spl_autoload_register();
use Service\Mail\GmailServer;
$server = new $SERVER(USERNAME, PASSWORD);
While, of course, this is working:
$server = new GmailServer(USERNAME, PASSWORD);
Am i'm missing something?
EDIT: Working with reflection (but you HAVE to specify the full namespace):
$reflector = new \ReflectionClass("Service\\Mail\\$SERVER");
$server = $reflector->newInstance(USERNAME, PASSWORD);
GmailServer.phpexists in the current folder?new GmailServerone line below will work.GmailServeris already inService/Mailfolder, thanks for helping.$SERVER = 'Service\Mail\GmailServer';