zoukankan      html  css  js  c++  java
  • 板邓:PHP解决Using $this when not in object context in【转】

    错误信息:$this引用没有上下文

    原因:在PHP5中,static声明的静态方法里不可以使用$this 需要使用self来引用当前类中的方法或是变量。

    示例代码如下:

    <?php  
    namespace syhladminpage
    ecord;  // 命名空间  
      
    require_once  dirname(__FILE__).'/../../../../common/smarty_loader.php';    
      
    class record {  
        
          
         public static function exec($smarty) {      
              
            $ttr=self::getres();  
            $smarty->assign("arr",$ttr);        
            $smarty->display ( 'rec_mgr.html' );  
        }  
       function getres(){  
          $arr = array (    
           "1" => 'test',    
           '2' => 'me',    
           array (    
            "3" => "beij",    
            "4" => "zz"    
           ),    
           array (    
            "5",    
            "6" => "ewrwer",    
            "7" => "ssss"    
           )    
          );    
          return $arr;  
        }  
    }  
    record::exec($smarty);  
      
    ?>  
    板邓个人博客:http://8dseo.com
  • 相关阅读:
    丑数(摘)
    queue 之团队队列(摘)
    stack 集合栈计算机 (摘)
    反片语(map)
    stl的集合set——安迪的第一个字典(摘)
    stringstream函数(i o)
    T
    S
    R
    java面试题
  • 原文地址:https://www.cnblogs.com/xbdeng/p/7008301.html
Copyright © 2011-2022 走看看