After PHP 5.3, use was added to refer to the namespace,
and then something like:
use Tool\tool;
new tool();
Such a simplified operation.
However, I know of three ways a namespace can be called without using use:
1. Unlimited method new tool()
2. Limitation method new Tool\tool()
3. Fully qualified method new \Tool\tool()
Now I understand the operation method that does not require use to introduce the namespace, that is, the above 3 methods. Then the question is:
use Tool\tool;
and
use \Tool\tool;
What's the difference? The information cannot be found either. Help
============================ The problem has been solved and the answer is as follows ============= =========================
Leading backslashes are unnecessary and not recommended because imported names must be fully qualified and will not be resolved relative to the current namespace.
As shown in the picture:
![](http://img.php.cn/upload/image/000/000/000/2293c776bc8436a5afd4d4057530e8e5-0.png)
Attached is the address: http://php.net/manual/zh/lang...
Attached text:
So, there is no difference, and it is not recommended to write root''.
@wujunze
@anonymous66
@corki
use
I think it can be understood that the qualified method and the non-qualified method can be understood as the difference between the relative path when we import the file and the absolute path when we import the file. They are just a bit the same. I don’t know if I understand it correctly. Please correct me. Thanks!!!
use Tooltool
starts from the root namespace of the projectuse Tooltool
starts from the namespace in the current directory