
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP 7 - use Statement
From PHP7 onwards, a single use statement can be used to import Classes, functions and constants from same namespace instead of multiple use statements.
Example
<?php // Before PHP 7 use com\tutorialspoint\ClassA; use com\tutorialspoint\ClassB; use com\tutorialspoint\ClassC as C; use function com\tutorialspoint\fn_a; use function com\tutorialspoint\fn_b; use function com\tutorialspoint\fn_c; use const com\tutorialspoint\ConstA; use const com\tutorialspoint\ConstB; use const com\tutorialspoint\ConstC; // PHP 7+ code use com\tutorialspoint\{ClassA, ClassB, ClassC as C}; use function com\tutorialspoint\{fn_a, fn_b, fn_c}; use const com\tutorialspoint\{ConstA, ConstB, ConstC}; ?>
Advertisements