1
I have a class called MinPDO and within it a function called connect:
class MinPDO {
    public $sgbd = "mysql";
    public $dbhost = "localhost";
    public $dbname = "minpdo";
    public $dbuser = "root";
    public $dbpass = "";
    public function connect() {
        try {
            $conn = new PDO("{$this->sgbd}:host={$this->dbhost};dbname={$this->dbname};charset=utf8;", $this->dbuser, $this->dbpass);
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            $conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
            return $conn;
        } catch (PDOException $ex) {
            echo "<br><b>Error:</b> " . $ex->getMessage();
            return false;
        }
    }
}
How can I call her that?
MinPDO::connect();
At the moment I’m doing so:
$mnpdo = new MinPDO();
$mnpdo->connect();
According to some programmers it would be more useful to call it the first way, but how do I do it?
Declaring the variables and the method as
static.– user28595