What does PHP namespace use mean?

Source: Internet
Author: User
{Code...} is this a help document that someone else gave me about use? Namespacefoo; I know, it should be a space called foo; useMyFullClassnameasAnother; what does it mean? As I understand, is the alias mysql also has this syntax useMyFullClassname I...

  

This is a help document that someone else gave me about use?
Namespace foo; I know, it should be a space called foo;
Use My \ Full \ Classname as Another; what does it mean?
As, I understand, the alias mysql also has this syntax

Use My \ Full \ Classname
I don't understand,
Question 1:
Use My \ Full \ Classname means to use My \ Full \ Classname space?

Question 3:
Is My \ Full a space path? Is classname a class name?
Or is My \ Full \ classname a path?

Where can I write My \ Full \ classname? Or where is the space Path MyFull?

No namespace exists in this PHP file, so it should not be in this file,
Where is this file not located?
Neither include () nor require ().
Is it in another file?
Where is this file? There are countless files on the computer. How does he know where the file is?
After opening this file, will he traverse the entire computer?

Question 2:
What can I do after use My \ Full \ Classname?

If include ("1.php");, you can use the variable functions in 1.php,
But what can I do with use My \ Full \ Classname?

I wrote the following two files:


  
 

Why can't aValue be output ???

Reply content:

    

This is a help document that someone else gave me about use?
Namespace foo; I know, it should be a space called foo;
Use My \ Full \ Classname as Another; what does it mean?
As, I understand, the alias mysql also has this syntax

Use My \ Full \ Classname
I don't understand,
Question 1:
Use My \ Full \ Classname means to use My \ Full \ Classname space?

Question 3:
Is My \ Full a space path? Is classname a class name?
Or is My \ Full \ classname a path?

Where can I write My \ Full \ classname? Or where is the space Path MyFull?

No namespace exists in this PHP file, so it should not be in this file,
Where is this file not located?
Neither include () nor require ().
Is it in another file?
Where is this file? There are countless files on the computer. How does he know where the file is?
After opening this file, will he traverse the entire computer?

Question 2:
What can I do after use My \ Full \ Classname?

If include ("1.php");, you can use the variable functions in 1.php,
But what can I do with use My \ Full \ Classname?

I wrote the following two files:


    
 

Why can't aValue be output ???

Use indicates that I want to use this item, which can be abbreviated later. For example

use Project\Model\Table;$table = new Table();

To put it simply, if use is used, you only need to use the name after the last slash or the alias specified by the as. In the above example, if use is not used, the equivalent code is

$table = new \Project\Model\Table();

The file you wrote failed because you didn't have a good example. It should be

use const yangbin\a\aValue;echo aValue;

You can think that the namespace is a path, and then use the namespace to complete the class name = namespace path + class name

For include/require, this has nothing to do with use. I told you before that it can be abbreviated when I use it and then call it later. Other functions are useless. Therefore, if automatic loading fails, you can include it yourself. You can search for automatic loading by yourself.

Based on your questions, you are a newbie and have almost no programming experience, lack of association and reasoning capabilities. We suggest you think more. In fact, this thing has a lot of reference, such as the disk path, alias usage, it is not difficult to understand, but your lack of other aspects of the basic causes difficulties in understanding.

In addition, be careful. No, it's normal. It's certainly not right to write a few words at will. The first step is to carefully read the document, first correct it, and then gradually modify it. If you have any questions, you can ask them if you really want to understand it, for example, if your question involves namespaces, classes, functions, constants, file references, and automatic loading, it is hard for others to answer. You have entered hundreds of words to describe the question, i'm afraid it may take thousands of words to answer in detail. It makes sense to spend so much time without a dime? So a brief answer is provided at most, but you can't understand the endless loop.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.