Right. For example.
We have an init file.
PHP Code:
<?php
include_once 'database.core.php';
$database = new database();
?>
Now, I could change that around and have this.
PHP Code:
<?php
// Include configuration file.
include_once 'config.php';
include_once 'database.core.php';
$database = new database($dbHost, $dbUsername, $dbPassword, $dbName);
and have my config file like this
PHP Code:
<?php
$dbHost = 'localhost';
$dbUsername = 'Username';
$dbPassword = 'Password';
$dbName = 'dbname';
Then this part in our init.php file:
$database = new database($dbHost, $dbUsername, $dbPassword, $dbName);
That is basically saying
$database = new database('localhost', 'Username', 'Password', 'dbname');
as you probably know. So it is creating our database class and sending variables to it.
Now, to handle those variables, I would do something along the lines of:
PHP Code:
<?php
class database {
function __construct($dbHost, $dbUsername, $dbPassword, $dbName){
// Mysql connection jazz goes here using them connection details.
}
}
__construct is basically run when you do new object.
So in this case I do new database in my php which tells the script or w/e to check for a construct in my database class. You have done functions before so you match them yeh and you can connect using them. Doing $database = new database() blah is a nice easy way of doing it. You can then do things such as set the links for queries to use and theres alot you can do but I'm not going into detail.