Results 1 to 3 of 3
Aug 11, 2013, 01:13 #1
- Join Date
- May 2006
- 2 Post(s)
- 0 Thread(s)
Dynamic fully qualified namespaces - good or bad?
I'm quite new to namespaces though I am now sold on the idea and think they're excellent. My main gripe was though that the scope of a use statement was only in the file it was called. So, in my current project outside of the bootstrap file I have loads of fully qualified namespaces. E.g.
$object = new \Vendor\Package\Class($parameter);
I have just found out as of 5.3 (which I'm using) you can call classes through variables—including namespaces. So I guess I could do something like:
$package = '\Vendor\Package\\';
$currentPackage = $package . 'Class';
$object = new $currentPackage($parameter);