[PHP] Autoloading namespace

Status
Not open for further replies.

GarettM

Posting Freak
Aug 5, 2010
833
136
okay i know the Autoloader class works and it finds the file but this is what i wanna do

PHP:
 $this->controller = 'Main'
PHP:
<?php
if(class_exists("Controller\$this->controller", true))
{
    $this->controller = new Controller\{$this->controller}();
}
?>

How can i link the variable to the class?

Here is the error i get..
Code:
   Parse error: syntax error, unexpected '{', expecting identifier (T_STRING)

So i am guessing this is illegal
PHP:
 $this->controller = new Controller\$this->controller();
does anyone know how i can link the controller\$this->controller to $this->controller
:)

EDIT : I figured it out....

PHP:
$controller = "{Controller\\$this->controller()}";

if(class_exists($controller, true))
{
    $this->controller = new $controller;
}
Sorry please close thread!
 
Last edited:
Status
Not open for further replies.

Users who are viewing this thread

Top