How can the use of parameters in PHP constructors help reduce tight coupling between classes?

Tight coupling between classes occurs when one class is highly dependent on another, making it difficult to change one class without affecting the other. By using parameters in PHP constructors, we can pass in dependencies rather than hardcoding them within the class. This allows for greater flexibility and easier testing, as classes can be easily swapped out or modified without impacting the overall system.

class DatabaseConnection {
    private $host;
    private $username;
    private $password;
    
    public function __construct($host, $username, $password) {
        $this->host = $host;
        $this->username = $username;
        $this->password = $password;
    }
    
    // Other methods that use the database connection
}

// Usage
$connection = new DatabaseConnection('localhost', 'root', 'password');