Usage of import in Thinkphp

Source: Internet
Author: User
This article mainly introduces several import usage in Thinkphp. For more information, see ThinkPHP.

The following describes the usage of import.

1. usage 1

Import ('@. Test. Translate ');
@ Indicates the project root directory. Assume that the root directory is: App/
The path to import the class library is App/Lib/Test/Translate. class. php.
Conclusion: import ('@') is relative to the Lib Directory of the project directory.

2. usage 2

Import ('Think. Test. Translate ');
Think indicates the system root directory. Both:./ThinkPHP/
The path to import the class library is./ThinkPHP/Lib/Test/Translate. class. php.
Conclusion: import ('think') is relative to the Lib Directory of the system directory.

3. usage 3

Import ('org. Test. Translate ');
Or
Import ('com. Test. Translate ');
ORG, third-party public class library directory
COM, Enterprise Public Class Library Directory
Both methods are relative to./ThinkPHP/Extend/Library.
The path to import the class Library is./ThinkPHP/Extend/Library/ORG/Test/Translate. class. php.
Or
The path to import the class Library is./ThinkPHP/Extend/Library/COM/Test/Translate. class. php.

Conclusion: import ('org ') or import ('com') is relative to the System Extension class Library directory (./ThinkPHP/Extend/Library /)

4. usage 4

Import ('Blog. Test. Translate ');
This method is neither @ nor Think, nor ORG or COM, and will be processed as the project directory of the group.
Resolution result: App/../Blog/Lib/Test/Translate. class. php
Conclusion: The fourth method is relative to the Lib Directory of the group Project Directory.

5. usage 5

Import also supports alias import. to import aliases, first define the alias file and create alias. php under the project configuration directory to define the class library alias to be used in the project.

Return array ('page' => LIB_PATH. 'common/page. class. php',); // you can use this method to import ('page ');

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.