PHP TP Namespace

Source: Internet
Author: User
<span id="Label3"><p>Namespaces: equivalent to a virtual directory (using namespaces to load classes Automatically)</p><p>Normal Administrative files use Folder management (physical Distinction)</p><p>namespace Home (level namespace) \controller (level two namespace);<br>Use Think\controller (file name);</p><p>Root namespace<br>1. System's Class Library Directory (thinkphp/library)<br>2. The root of the class library namespace in the module (Home) is named after the module name</p><p>The root namespace of the TP framework Is: thinkphp\library<br>Within the TP framework the namespace is used \ represents the root namespace (thinkphp\library)</p><p>1. The root namespace under the system directory is named after the Thinkphp\library folder name</p><p>2. The Module's root namespace is named after the module name</p><p>You need to write from the root when defining a namespace for example: home\controller: Think\model</p><p><br>If you want to use a class file, introduce that class of namespaces:<br>Using the use keyword, followed by the namespace after the class is appended with "\ filename"</p><p>If you do not want to introduce namespaces: you can use \ (the initial namespace) to find the corresponding class when creating objects of your class<br>For example: New \think\page (30);</p><p>PHP TP Namespace</p></span>

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.