Created
October 12, 2023 03:28
-
-
Save 4RSIM3R/ba48915c03e392a1fc5b3a0f0330dad3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// fix this error please | |
class DBConnection | |
{ | |
private $connection; | |
public function __construct($connection) | |
{ | |
$this->connection = $connection; | |
} | |
public function connect() | |
{ | |
echo sprintf("Connecting to %s", $this->connection); | |
} | |
} | |
class MysqlConnection | |
{ | |
private $connection = "mysql"; | |
} | |
class PgsqlConnection | |
{ | |
private $connection = "pgsql"; | |
} | |
function connect(DBConnection $connection) | |
{ | |
$connection->connect(); | |
} | |
connect(new MysqlConnection()); // Connecting to mysql | |
echo "<br />"; | |
connect(new PgsqlConnection()); // Connecting to pgsql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment