代码整合如下:
<code><?php
abstract class Model{
protected $table = NULL;
protected $db = NULL;
public function __construct(){;
var_dump(MySQL::getIns());
$this->$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);
?></code>会出现:Fatal error: Cannot access empty property in F:\Apache2.2\htdocs\emec\test.php on line 9
去掉基类的abstract问题依旧。
环境:apache2.2 php5.3.5
代码整合如下:
<code><?php
abstract class Model{
protected $table = NULL;
protected $db = NULL;
public function __construct(){;
var_dump(MySQL::getIns());
$this->$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);
?></code>会出现:Fatal error: Cannot access empty property in F:\Apache2.2\htdocs\emec\test.php on line 9
去掉基类的abstract问题依旧。
环境:apache2.2 php5.3.5
写多了一个$
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号