I was wondering what is the best practice for PHP/MySQL development.

For example, I have the following:

* connect.php
* close.php

In connect.php, it uses `require_once('classes/database.php')` and uses `$database = new database();` then calls `$database->connect();`

Should I require\_once these into say a header.php and a footer.php and have an overall connection (every main webpage includes these), or, instead open and close it for when I need it. For example I have a functions.php file that has functions which should I do:

```
public function test() {
    $db = new database();
    // db setup here
    $db->connect();
    // do stuff here
    $db->disconnect();
}

```

or

```
public function test() {
    // stuff here
}

```

Thanks!