I was reading a blog post when I came across this code:
<?php
include_once 'config.php';
class User
{
//Database connect
public function __construct()
{
$db = new DB_Class();
}
In the comments someone posted the following:
NEVER INITIATE db connection in the constructor
But as with all comment warriors they never give a reason why? Why is this wrong or a bad practice to do?