stuck on this. Lets start with code.
Settings.php
class settings{
public $db_host;
public $db_username;
public $db_password;
public $db_database;
public function db_settings(){
/*$db_host = "localhost";
$db_username = "root";
$db_password = "";
$db_database = "eveonline";*/
$this->db_host = "localhost";
$this->db_username = "root";
$this->db_password = "";
$this->db_database = "eveonline";
}
This is where I want to use this
class xmlUpdate{
include_once ('./lib/settings.php'); //This wont work
public $itemCount;
public function dbItemCount(){
include_once ('./lib/settings.php');// This will work, but only in this function
In this case its for database varables, so I dont have to duplicate code whenever I want to make a database connection.
How can I use the database varables in another class, the whole class, not just the function where it allows me to include?
I would put the include into the
__construct()function of your class, instantiate a new Class, read out the variables put them in local variables in your class.Or you could make you xmlUpdate class extend the settings class.