• 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');
  • 相关阅读:
    ZOJ Problem Set
    ZOJ Problem Set
    ZOJ Problem Set
    ZOJ Problem Set
    ZOJ Problem Set
    387.First Unique Character in a String
    169. Majority Element
    postgresql 导出函数的方法
    455. Assign Cookies.md
    python模拟shell执行脚本
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/5173232.html
Copyright © 2020-2023  润新知