Usage of import in Thinkphp

Source: Internet
Author: User

The following is a description of Several import operations. 1. Usage 1.

Import ('@. Test. translate'); @, indicating the project root directory. Assume that the root directory is: App/import class library path 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, indicating the system root directory. Not only :. /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, the third-party public class library directory COM, and the enterprise public class library directory are both relative. /ThinkPHP/Extend/Library. The path to import the class library is :. /ThinkPHP/Extend/Library/ORG/Test/Translate. class. php or the path for importing 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. The resolution result is 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.