php_nub_qq Posted May 9, 2013 Share Posted May 9, 2013 public static $info=array(); private static $instance=null; public static function _new($fields = null){ if(self::$instance == null){ self::$instance = new User(); } if(!empty($fields) && !empty(self::$info['id'])){ self::$info = $this->getUserInfo(self::$info['id'], $fields); } return self::$instance; } self::$info = $this->getUserInfo(self::$info['id'], $fields); This is the line where I get " Fatal error: Using $this when not in object context " Why is that? Link to comment https://forums.phpfreaks.com/topic/277842-this-when-not-in-object-context/ Share on other sites More sharing options...
ignace Posted May 9, 2013 Share Posted May 9, 2013 $this is only available when you have instantiated an object. In a static content is $this not available. I think you mean: self::$info = self::$instance->getUserInfo(self::$info['id'], $fields); Link to comment https://forums.phpfreaks.com/topic/277842-this-when-not-in-object-context/#findComment-1429318 Share on other sites More sharing options...
php_nub_qq Posted May 9, 2013 Author Share Posted May 9, 2013 In the words of Homer Simpson - Doh! Link to comment https://forums.phpfreaks.com/topic/277842-this-when-not-in-object-context/#findComment-1429327 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.