欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

Fatal error: Cannot access empty property

程序员文章站 2022-05-18 19:44:28
...
代码整合如下:
$db = MySQL::getIns();
    }
}

class catModel extends Model{
    protected $table = 'emec_cat';
    public function addCat($date){
      $sql = $this->db->Autoexpr($date);
      return $this->db->qurey($sql);
    }
} 

class MySQL {

        static protected $Ins;
        protected $res;



        static function getIns(){
            if(self::$Ins instanceof self){
                return self::$Ins;
        }
            self::$Ins = new MySQL();
            return self::$Ins;
        }

        private function __construct(){
            $this->res = 1;
        }

        protected function __destruct(){
            mysql_close($link);
        }
}

$date = array();
$date['cat_name'] = $_POST['cat_name'];
$date['parent_id'] = $_POST['parent_id'] + 0;
$date['intro'] = $_POST['intro'];
$catMode = new catModel();
$catMode->addCat($date);
 ?>

会出现:
Fatal error: Cannot access empty property in F:\Apache2.2\htdocs\emec\test.php on line 9
去掉基类的abstract问题依旧。
环境:
apache2.2 php5.3.5

回复内容:

代码整合如下:

$db = MySQL::getIns();
    }
}

class catModel extends Model{
    protected $table = 'emec_cat';
    public function addCat($date){
      $sql = $this->db->Autoexpr($date);
      return $this->db->qurey($sql);
    }
} 

class MySQL {

        static protected $Ins;
        protected $res;



        static function getIns(){
            if(self::$Ins instanceof self){
                return self::$Ins;
        }
            self::$Ins = new MySQL();
            return self::$Ins;
        }

        private function __construct(){
            $this->res = 1;
        }

        protected function __destruct(){
            mysql_close($link);
        }
}

$date = array();
$date['cat_name'] = $_POST['cat_name'];
$date['parent_id'] = $_POST['parent_id'] + 0;
$date['intro'] = $_POST['intro'];
$catMode = new catModel();
$catMode->addCat($date);
 ?>

会出现:
Fatal error: Cannot access empty property in F:\Apache2.2\htdocs\emec\test.php on line 9
去掉基类的abstract问题依旧。
环境:
apache2.2 php5.3.5

写多了一个$

相关标签: php