What is the usage of php7 use

藏色散人
Release: 2023-02-17 17:10:01
Original
3921 people have browsed it

php use means that you can use a use in PHP to import classes, functions and constants from the same namespace. The usage statement is "use some\namespace\ClassA; use some\namespace\ClassB;".

What is the usage of php7 use

PHP 7use statement

PHP 7 can be used A use imports classes, functions and constants from the same namespace:

Example

// PHP 7 之前版本需要使用多次 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+ 之后版本可以使用一个 use 导入同一个 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}; ?>
Copy after login

The above is the detailed content of What is the usage of php7 use. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!