1. In the thinkphp3.2 era, namespaces were not used, but the code did not look very complicated, and it did not cause much inconvenience.
2. I had seen a project done by others before. Namespace, it seems that each class file actually uses many namespaces
3. Is namespace really necessary? Will not using it cause inconvenience?
When many of the classes you introduce have the same name, you will know the role of namespace.
For example, there is aUser
class in Domain, a
Userclass in Service, and a
Userclass in Web.
When discussing problems, why do we always use tp as an example
For large projects, it is necessary
Otherwise, it would be bad if different libraries are introduced and functions with the same name are confused
Modern php is needed
Maybe you don’t feel the role of namespaces in the projects you are exposed to now, but people should look forward. The same is true for language updates. Everything is reasonable if it exists. As for the role of namespaces, I won’t say much about it. Whatever. Google will tell you a lot about why you should use namespaces. You just need to know that it will be better if you use it. Don't people develop in a better direction?
When discussing problems, why do we always use tp to give examples 111
Maybe you don’t feel the role of namespaces in the projects you are exposed to now, but people should look forward. The same is true for language updates. Everything is reasonable if it exists. As for the role of namespaces, I won’t say much about it. Whatever. Google will tell you a lot about why you should use namespaces. You just need to know that it will be better if you use it. Don't people develop in a better direction?
In fact, the main purpose of namespace is to solve the problem of conflicts between classes with the same name.
Before there was no namespace, the old-fashioned way was to name classes according to
classmap
. For example, the writing method ofSystem_Controller.php
underline; changes to the current writing method ofSystemController
;Whether it is
classmap
or namespace, just follow certain rules and then introduce it throughspl_autoload_register
. It will not cause class name conflict; namespace is not necessary in the project, it is just a product of technological development!Besides, this is very similar to other languages (such as java, etc.). Everyone is like this. If PHP is not like this, it will not keep up with the trend. . Ha ha! !