我有一个基类和一个扩展基类的第二个类。问题是我无法从子类访问 $db 对象,而是所有普通变量。知道为什么吗?
class Base_Login
{
protected $member_uri = 'member.php';
protected $db;
public function __construct($db_user, $db_password, $db_name, $db_host)
{
$this->db = new ezSQL_mysql($db_user, $db_password, $db_name, $db_host);
var_dump($this->db); //Output: Object content's
}
}
class Facebook_Login extends Base_Login
{
public function __construct($app_id, $secret)
{
var_dump($this->db); //Output: NULL
echo $this->member_uri //Output: member.php
}
}
这就是我所说的:
require("includes/config.php");
$base_login = new Base_Login($db_user,$db_password,$db_name,$db_host);
$base_login->Facebook_Login = new Facebook_Login($facebook_appID,$facebook_secret);