class.user.php内 あなたが持っている:
function __construct($DB_con)
{
$this->db = $DB_con;
}
logout.phpで使用する場合 :
$user = new USER();
$DB_conを渡す必要があります __constructorへ 、または__constructorを作成します 引数がなく、DBを初期化する別の関数を追加します :
function __construct()
{
}
public function initDB($DB_con)
{
$this->db = $DB_con;
}
そして、あなたはそれをそのように使うことができます:
$YourDB = whatever_get_DB();
$user = new USER();
// And when you need:
$user.initDB($YourDB);
またはこれなしのみ:
$YourDB = whatever_get_DB();
$user = new USER($YourDB);