mysqli_connect

FunctionMisc changes in PHP 8.2

Alias of mysqli::__construct.

PHP 5
PHP 7
PHP 8.0
Improved
PHP 8.1
PHP 8.2
Changed
PHP 8.3
PHP 8.4
PHP 8.5
PHP 8.6

mysqli_connect Function synopsis

mysqli_connect(
    ?string $hostname = null,
    ?string $username = null,
    ?string $password = null,
    ?string $database = null,
    ?int $port = null,
    ?string $socket = null
  ): mysqli|false

Parameters

$hostname

OptionalType?stringDefault valuenull

$username

OptionalType?stringDefault valuenull

$password

OptionalType?stringDefault valuenull

$database

OptionalType?stringDefault valuenull

$port

OptionalType?intDefault valuenull

$socket

OptionalType?stringDefault valuenull

Return value

Typemysqli|false

Changes to the mysqli_connect Function

PHP 8.2

PHP 8.0

  • Return type added: mysqli|false
  • Parameter name of parameter #1 changed: $host to $hostname
  • Parameter type added for parameter #1 ($hostname): ?string
  • Parameter default value added for position #1 ($hostname): null
  • Parameter name of parameter #2 changed: $user to $username
  • Parameter type added for parameter #2 ($username): ?string
  • Parameter default value added for position #2 ($username): null
  • Parameter type added for parameter #3 ($password): ?string
  • Parameter default value added for position #3 ($password): null
  • Parameter type added for parameter #4 ($database): ?string
  • Parameter default value added for position #4 ($database): null
  • Parameter type added for parameter #5 ($port): ?int
  • Parameter default value added for position #5 ($port): null
  • Parameter type added for parameter #6 ($socket): ?string
  • Parameter default value added for position #6 ($socket): null
  mysqli_connect(
-     $host,
+     ?string $hostname = null,
-     $user,
+     ?string $username = null,
-     $password,
+     ?string $password = null,
-     $database,
+     ?string $database = null,
-     $port,
+     ?int $port = null,
-     $socket
+     ?string $socket = null
-   )
+   ): mysqli|false

mysqli_connect Function Availability

PHP VersionAvailability
PHP 8.6Upcoming Release Yes
PHP 8.5Supported (Latest) Yes
PHP 8.4Supported Yes
PHP 8.3Security-Fixes Only Yes
PHP 8.2Security-Fixes Only Yes
PHP 8.1Unsupported Yes
PHP 8.0Unsupported Yes
PHP 7.4Unsupported Yes
PHP 7.3Unsupported Yes
PHP 7.2Unsupported Yes
PHP 7.1Unsupported Yes
PHP 7.0Unsupported Yes
PHP 5.6Unsupported Yes
PHP 5.5Unsupported Yes
PHP 5.4Unsupported Yes
PHP 5.3Unsupported Yes