Attached below are some introductions to how to use import
1. Usage 1
import('@.Test.Translate');
@, indicates the project root directory. Assume 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, represents the system root directory. Either: ./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 writing 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 way of writing is neither @, Think, nor ORG, COM, and will be treated as a grouped project directory.
The parsing result is: App/../Blog/Lib/Test/Translate.class.php
Conclusion: The fourth way of writing is relative to the Lib directory of the grouped project directory.
5. Usage 5
Import also supports alias import. To use alias import, first define the alias file, create alias.php in the project configuration directory, and define the class library aliases that need to be used in the project.
return array( 'page' => LIB_PATH.'Common/page.class.php', ); //这样使用即可 import('page');