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.
From PHP 7.0 onwards, classes, functions, and constants being imported from the same namespace can be grouped together in a single
usestatement.
Like this way:
use com\test\{ClassA, ClassB}; $a = new ClassA; $b = new ClassB; Read more here: PHP Manual for Aliasing/Importing
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; test not com\test, you would have to remove the beginning "\" for it to be using the alias test