正如标题所说,我的情况如下:
require_once("connect.php") //database connection file
class one {
private $mysqli;
function __construct ($dbi) {
$this -> mysqli = $dbi;
}
function one {
// ... function using things like $this -> mysqli -> prepare and so on...
}
}
并且,在同一个文件中:
class two {
private $mysqli;
function __construct ($dbi) {
$this -> mysqli = $dbi;
}
function two {
// here I need to access the function "one" of the class "one"
// If i do something like $one = new one ($mysqli) I get an error on the __construct
}
}
我真的很生气,但我相信这并不难,因为我是 PHP 中 OOP 的初学者。希望那里的人可以帮助我。