class Database { private static $instance = null; private $conn; private function __construct() { $host = 'localhost'; $user = 'root'; $pass = 'password'; $db = 'my_db'; try { $this->conn = new PDO("mysql:host=$host;dbname=$db;charset=utf8", $user, $pass); } catch (PDOException $e) { // handle connection error } } public static function getInstance() { if(!self::$instance) { self::$instance = new Database(); } return self::$instance; } public function getConnection() { return $this->conn; } } // usage example $db = Database::getInstance(); $conn = $db->getConnection();In this example, the "getInstance" method is used to create a singleton instance of the "Database" class, which contains a private PDO connection. The "getConnection" method is then used to retrieve the connection and execute SQL queries. Overall, the "getInstance" method is a useful pattern for managing database connections in PHP applications, and is commonly found in database abstraction libraries like PDO.