Home > PHP Framework > ThinkPHP > Parse ThinkPHP namespace

Parse ThinkPHP namespace

藏色散人
Release: 2020-05-17 15:52:58
forward
2816 people have browsed it

The following tutorial column developed by thinkphp will analyze the namespace of ThinkPHP for everyone. I hope it will be helpful to friends in need!

Parse ThinkPHP namespace

We all know that since PHP syntax does not support the function overloading mechanism, what should we do if there are two methods with the same name in an application?

In the Yii framework, in order to avoid problems caused by name duplication, all classes have the words C in front of them, and the concept of namespace is introduced in ThinkPHP.

a) The namespace is a virtual definition space, not a real directory

b) The delimiters of the namespace are all backslashes\

c) Unqualified name: getName() Get the name of its nearest namespace getName()

d) Qualified name: beijinggetName() Relative method

Locate through the nearest namespacebeijinggetName(): As in the example below, he will think that beijinggetName() is in the current directory, so Will find dalianbeijinggetName(). At this time, an error will be reported because it cannot be found! !

e) Fully qualified name: beijinggetName() Get specific elements directly in the specified namespace

f) Namespace targets: functions, class names, and constants Its function is to collectively refer to these three elements in the namespace.

The operation examples are as follows:

Parse ThinkPHP namespace

##Related recommendations: "

TP5

The above is the detailed content of Parse ThinkPHP namespace. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
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 Issues
Why thinkphp has better performance than laravel?
From 1970-01-01 08:00:00
0
0
0
ThinkPHP Why use composer?
From 1970-01-01 08:00:00
0
0
0
thinkphp versions supported by php6
From 1970-01-01 08:00:00
0
0
0
thinkphp upload files
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template