Say a database class for instance?
This way my database class only has to make one connection, and all of my modules can use it, then close at the very end?
Otherwise, right now I'm created the database class at the top, then passing it to the needed classes
Example
index.php
Code: Select all
$database = new Database();
$database->connect();
$login = new Login($database);
$page = new Page($database, "Index.html");
$database->close();
index.php
Code: Select all
$_SESSION['database'] = new Database();
$_SESSION['database']->connect();
$login = new Login();
$page = new Page("Index.html");
$_SESSION['database']->close();