Home  >  Article  >  Backend Development  >  为啥命名空间里的use后面没有as

为啥命名空间里的use后面没有as

WBOY
WBOYOriginal
2016-06-23 13:44:34784browse

大家知道命名空间里的use语法规则规定其后面必须跟as起个别名,但是thinkphp官方代码中却没有跟as,这到底是怎么回事呢


回复讨论(解决方案)

只要命名空间 Think 中存在 Controller 类
那么
use Think\Controller

use Think\Controller as Controller
是等价的

况且你在整个 thinkphp 代码中都不会找到 namespace Think\Controller 这样的命名空间声明

只要命名空间 Think 中存在 Controller 类
那么
use Think\Controller

use Think\Controller as Controller
是等价的

况且你在整个 thinkphp 代码中都不会找到 namespace Think\Controller 这样的命名空间声明


这样解释是错误的,正确的答案是,use是引用作用,即表示引用别的页面中数的一个方法,看来你的基础知识也不怎么行
Statement:
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