I posted some questions previously regarding the use of Namespaces in PHP and from what I got, this example code I have below should be working.
However I am getting
Even when using use
statement, you need to specify the namespace of the class you are trying to instantiate. There are a lot of examples here: http://www.php.net/manual/en/language.namespaces.importing.php
To understand it better, I will describe to you how it works. In your case, when you do use \Controller
, the whole Controller
namespace becomes available to you, but not the classes that are in this namespace. So, for example:
show();
?>
Another example:
testcontoller.php:
Was run inside testcontroller.php
';
}
}
?>
testing.php:
show();
?>
If you wish to import exactly the Controller
class, you need to do use Controller\Controller
- then this class will be accessible in your current scope.