Thinkphp里import的几个用法介绍
下面附上import的几个用法介绍
1、用法一
import('@.Test.Translate'); @,表示项目根目录。假定根目录是:App/ 导入类库的路径是:App/Lib/Test/Translate.class.php 结论:import('@')是相对于项目目录的Lib目录而言
2、用法二
import('Think.Test.Translate'); Think,表示系统根目录。既是:./ThinkPHP/ 导入类库的路径是:./ThinkPHP/Lib/Test/Translate.class.php 结论:import('Think')是相对于系统目录的Lib目录而言
3、用法三
import('ORG.Test.Translate'); 或 import('COM.Test.Translate'); ORG, 第三方公共类库目录 COM, 企业公共类库目录 两种写法都是相对于./ThinkPHP/Extend/Library/ 而言。 导入类库的路径是:./ThinkPHP/Extend/Library/ORG/Test/Translate.class.php 或 导入类库的路径是:./ThinkPHP/Extend/Library/COM/Test/Translate.class.php 结论:import('ORG')或import('COM')是相对于系统扩展类库目录而言(./ThinkPHP/Extend/Library/)
4、用法四
import('Blog.Test.Translate'); 这种写法既不是@,Think的写法,有不是ORG,COM的写法,会被当作分组的项目目录来处理。 解析结果是:App/../Blog/Lib/Test/Translate.class.php 结论:第四种写法,是相对于分组项目目录的Lib目录而言的写法。
5、用法五
import还支持别名导入,使用别名导入,首先先定义别名文件,在项目配置目录下建立alias.php,定义项目中需要用到的类库别名。
return array( 'page' => LIB_PATH.'Common/page.class.php', ); //这样使用即可 import('page');

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Huawei is rolling out software version 5.0.0.100(C00M01) for the Watch GT 5 and the Watch GT 5 Prosmartwatchesglobally. These two smartwatches recently launched in Europe, with the standard model arriving as the company’s cheapest model. This Harmony

Katsuhiro Harada, the Tekken series director, once seriously tried to bring Colonel Sanders into the iconic fighting game. In an interview with TheGamer, Harada revealed that he pitched the idea to KFC Japan, hoping to add the fast-food legend as a g

Earlier in September 2024, Anker's Zolo 140W charger was leaked, and it was a big deal since it was the first-ever wall charger with a display from the company. Now, a new unboxing video from Xiao Li TV on YouTube gives us a first-hand look at the hi

Garmin is ending the month with a new set of stable updates for its latest high-end smartwatches. To recap, the company released System Software 11.64 to combat high battery drain across the Enduro 3, Fenix E and Fenix 8 (curr. $1,099.99 on Amazon).

Xiaomi will shortly launch the Mijia Graphene Oil Heater in China. The company recently ran a successful crowdfunding campaign for the smart home product, hosted on its Youpin platform. According to the page, the device has already started to ship to

ThinkPHP6 routing parameters are processed in Chinese and complete acquisition. In the ThinkPHP6 framework, URL parameters containing special characters (such as Chinese and punctuation marks) are often processed...

Using the ThinkPHP6 framework combined with elasticsearch-php client to operate Elasticsearch...

ThinkPHP6 database query: How to use TP6 to implement SQL statements SELECTSUM(jin), SUM(chu)FROMsysdbuil In ThinkPHP6 framework, how to use SQL statement SELECT...
