The usage of import in Thinkphp is described in detail. The following describes the usage of import. 1. usage 1: import (@. Test. Translate); @, which indicates the project root directory. Assume that the root directory is: the path for the App to import the class library is: AppLibTestTransl, which is attached with several import usage descriptions.
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 ');
Example 1: usage 1 import ('@. Test. Translate'); @ indicates the project root directory. Assume that the root directory is: App/import class library path: App/Lib/Test/Transl...