search
HomePHP FrameworkThinkPHPDetailed explanation of namespace in THINKPHP

Detailed explanation of namespace in THINKPHP

May 16, 2020 am 09:25 AM
thinkphp

Detailed explanation of namespace in THINKPHP

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 word 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 getName()

d) of its nearest namespace Qualified name: beijinggetName() Relative method

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

e) Fully qualified name: beijinggetName() directly obtains the specific element in the specified namespace

f) The namespace targets: functions, class names, and constants. Their functions are in the namespace. These three types are collectively referred to as elements

The operation examples are as follows:

Detailed explanation of namespace in THINKPHP

Recommended tutorial: "TP5"

The above is the detailed content of Detailed explanation of namespace in THINKPHP. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools