The use of use keyword in php (including code)

烟雨青岚
Release: 2023-04-08 19:46:01
forward
3185 people have browsed it

The use of use keyword in php (including code)

Use of use keyword in php

1. use is most commonly used to retrieve classes Aliases can also be used in closure functions. The code is as follows


        
Copy after login

When running the test function, the test function returns the closure function. The variable in use in the closure function is $ in the test function. a variable, when the closure function is run, "hellohello" is output, which means that the priority of the variables in the function body is: the priority of the variables in use is higher than the priority of the closure function parameters.

2. The parameters in use can also be passed by reference. The code is as follows

Example 1

"; $fun(30,'wq'); echo "$b:$a
"; } test(); //结果是Ly:18 //结果是wq:30
Copy after login

Example 2

Copy after login

Thank you all for watching, I hope you can improve after learning how to use the use keyword.

Recommended tutorial: "PHP Tutorial"

The above is the detailed content of The use of use keyword in php (including code). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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!