PHP namespace Problems

Source: Internet
Author: User
{Code...} is this namespace equivalent to MyProjectSubLevel? Is MyProject The namespace under the global namespace by default?
php

Is this namespace equivalent to \ MyProject \ Sub \ Level?

Is MyProject The namespace under the global namespace by default?

Reply content:
php

Is this namespace equivalent to \ MyProject \ Sub \ Level?

Is MyProject The namespace under the global namespace by default?

You are right.

For more information, see http://www.chinaz.com/program/2010/0309/410172.shtml.

For the namespace issue, you 'd better try to write some code to verify your conjecture. This understanding will be much deeper and the memory will be enhanced.
Your understanding is correct. If you do not declare a namespace, the default namespace is '\', that is, the global namespace (PHP built-in functions, classes, and so on, except for the special declarations are all in this namespace ). You can useecho __NAMESPACE__. Verified

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.