Detailed introduction to several usages of import in Thinkphp_PHP tutorial

WBOY
Release: 2016-07-13 10:26:28
Original
672 people have browsed it

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');
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824662.htmlTechArticleAttached below are several usage introductions of import 1. Usage 1 import('@.Test.Translate'); @, indicates the project root directory. Assume that the root directory is: App/ and the path to import the class library is: App/Lib/Test/Transl...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!