tags:

views:

19

answers:

2

If I have some php classes inside a namespace com\test

and want to import all of them into another php file how can do that?

use com\test\ClassA
use com\test\ClassB
...

use com\test\* give me syntax error.

A: 

I think you can't do such thing.

You can do:

 use com\test

and refer to your classes at later time as:

test\ClassA
test\ClassB
Kamil Szot
+1  A: 

This should work:

use com\test;

$a = new \test\ClassA;
$b = new \test\ClassB;

or

use com\test\ClassA as ClassA;
use com\test\ClassB as ClassB;

$a = new ClassA;
$b = new ClassB;

See the PHP manual on Using namespaces: Aliasing/Importing.

Gordon
Very boring! Hope PHP developers will put that feature.
xdevel2000