Skip to content

Instantly share code, notes, and snippets.

@4RSIM3R
Created October 12, 2023 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4RSIM3R/ba48915c03e392a1fc5b3a0f0330dad3 to your computer and use it in GitHub Desktop.
Save 4RSIM3R/ba48915c03e392a1fc5b3a0f0330dad3 to your computer and use it in GitHub Desktop.
<?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