PHP and namespaces.
I assume that i missunderstood its correct usage/idea..
(please read to the end)
I have two files: 1.php
, 2.php
1.php:
namespace App\someNS;
class classname{}
2.php:
namespace App;
include_once("1.php");
use App\someNS; // tried to comment it also, not working
$ x = new classname();
// this fails..
My assumption is that namespaces are containers\scope, so by including one - I can access its content;
I expected that the use App\someNS
will "include" it.
I know that someNS\classname() will work, but I fails to see the big advantage in namespaces if the only "profit" from them, is the options to use the same names for variables, if after all i still need to use a path to get them... what am i missing?