静态方法中不能使用 $this

忽略了一个问题,$this 代表当前对象!! 静态方法中应该使用 类名 、 self 或者 static 关键字来代替!
    static
public function get_info($id) { var_dump($this); // NULL NULL 
       Fatal error: Using $this when not in object context in /home/apache/www/test/web/core/MY_Controller.php on line 80
}

 

posted @ 2016-07-22 09:40  1678924929  阅读(1505)  评论(0编辑  收藏  举报