php8.5
Home/ Manual/ pdo / pdo/ PDO::connect

PDO::connect

PHP function Edit on GitHub ✎

(PHP 8 >= 8.4.0)

Connect to a database and return a PDO subclass for drivers that support it

Description

PDO::connect(string $dsn, string|null $username = null, string|null $password = null, array|null $options = null): static

Creates an instance of a PDO subclass for the database being connected to, if it exists, otherwise returns a generic PDO instance.

Return Values

Returns an instance of a PDO subclass for the corresponding PDO driver if it exists, or a generic PDO instance.

See Also

  • Pdo\Dblib
  • Pdo\Firebird
  • Pdo\Mysql
  • Pdo\Odbc
  • Pdo\Pgsql
  • Pdo\Sqlite
  • PDO::__construct

Source: reference/pdo/pdo/connect.xml · from the official PHP manual (php/doc-en)