You don't even have to bother with a class or function. If you just put:
Quote:
|
$conn = mysqli_connect("blah", "blahblah", "meh", "mehmeh");
|
into the opendb.php, when you call require_once("opendb.php") it will open the connection. Turns 6 lines of code in your example into 2.
Now if you're going to be opening multiple concurrent connections to the same db for whatever reason, then your method is fine.