PHP 7 use statement
PHP 7 use statement
PHP 7 can use a use to import classes, functions and constants from the same namespace
Examples
// Versions before PHP 7 need to use multiple times use
use some\namespace\ClassA;
use some\namespace\ClassB;
use some\namespace\ClassC as C ;
use function some\namespace\fn_a;
use function some\namespace\fn_b;
use function some\namespace\fn_c;
use const some\namespace\ConstA ;
use const some\namespace\ConstB;
use const some\namespace\ConstC;
// PHP 7+ and later versions can use a use to import classes in the same namespace
use some\namespace\{ClassA, ClassB, ClassC as C};
use function some\namespace\{fn_a, fn_b, fn_c};
use const some\namespace\{ConstA, ConstB, ConstC};
?>
use some\namespace\ClassA;
use some\namespace\ClassB;
use some\namespace\ClassC as C ;
use function some\namespace\fn_a;
use function some\namespace\fn_b;
use function some\namespace\fn_c;
use const some\namespace\ConstA ;
use const some\namespace\ConstB;
use const some\namespace\ConstC;
// PHP 7+ and later versions can use a use to import classes in the same namespace
use some\namespace\{ClassA, ClassB, ClassC as C};
use function some\namespace\{fn_a, fn_b, fn_c};
use const some\namespace\{ConstA, ConstB, ConstC};
?>