How to introduce another space element in a namespace?

autoload
Release: 2023-03-08 15:36:01
Original
1537 people have browsed it

Space introduction method: useusekeywords

Copy after login

The elements introduced by space are classes by default. If you want to introduce other elements, you must use the corresponding keywords :functionandconst(if you need to introduce multiple elements of the same type, you need to use "," to separate them)

Copy after login

If You need to add multiple elements at the same time

Copy after login


If the introduced element already exists in the current space, there will be duplicate names. The solution is to use aliasesasKeyword for renaming

Copy after login

If all elements in a space need to be introduced, you can also directly introducespace

"; } } namespace n2; class OK{ public function __construct() { echo __NAMESPACE__."
"; } } //引入空间 use n1\n2; new OK(); //访问的是n2\OK new n2\OK(); //使用引入空间的最后一级空间访问 ?>
Copy after login

Recommended:php tutorial,php video tutorial

The above is the detailed content of How to introduce another space element in a namespace?. 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!