我这么写会提示错误
class Database{
protected $db;
static function getInstance(){
if(self::$db){
return self::$db;
}else{
self::$db = new self();
return self::$db;
}}
我这么写会提示错误Fatal error: Access to undeclared static property: Imooc\Database::$db in D:\WWW\test_820\Imooc\Database.php on line 21
但是如果我把 $db改成静态的就好了 求原因
static protected $db;