-1
我有兩個PHP類(DBOperations.php和functions.php)。現在我想從functions.php類的DBOperations.php類中設置一個值。PHP設置值的類
class DBOperations{
private $host = 'localhost';
private $user = 'u';
public $database;
private $pass = 'p';
private $conn;
public function __construct() {
$this -> conn = new PDO("mysql:host=".$this -> host.";dbname=".$this -> database, $this -> user, $this -> pass);
}
public function doMagic() {
//running mysql queries here
}
和functions.php中:
require_once 'DBOperations.php';
class Functions{
private $db;
public function __construct() {
$this -> db = new DBOperations();
}
public function doThings($variable) {
$db = $this -> db;
//here I want to set the value $database from the DBOperations class to //$variable
有人可以幫助NME了呢?
問候弗朗西斯
'$此函數屬性設置中的functions.php類的函數定義它 - >數據庫 - > database' –