zoukankan      html  css  js  c++  java
  • thinkphp

            $value = S('myval');
            if(!empty(S('myval'))){
                $temp = S('myval');
            }else{
               $paramet = "user_id/{$user_id}/page_num/{$page_num}";  
               $temp = $this->patterntwo($port,$paramet); 
               
               S('myval',$temp);
               $temp = S('myval');
               
            }
    
    下面附上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,定义项目中需要用到的类库别名。
    
    ?
    1
    2
    3
    4
    5
    6
    	
    return array(
    'page' => LIB_PATH.'Common/page.class.php',
    );
     
    //这样使用即可
    import('page');
    

    转载于:https://www.cnblogs.com/xiaoxiaomengxiangjia/p/7132530.html

  • 相关阅读:
    scala之伴生对象的继承
    scala之伴生对象说明
    “Failed to install the following Android SDK packages as some licences have not been accepted” 错误
    PATH 环境变量重复问题解决
    Ubuntu 18.04 配置java环境
    JDBC的基本使用2
    DCL的基本语法(授权)
    ZJNU 1374
    ZJNU 2184
    ZJNU 1334
  • 原文地址:https://www.cnblogs.com/twodog/p/12139986.html
Copyright © 2011-2022 走看看