mysqli_real_connect

FunctionMisc changes in PHP 8.2
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_real_connect Function synopsis

mysqli_real_connect(
    mysqli $mysql,
    ?string $hostname = null,
    ?string $username = null,
    ?string $password = null,
    ?string $database = null,
    ?int $port = null,
    ?string $socket = null,
    int $flags = 0
  ): bool

Parameters

$mysql

Typemysqli

$hostname

OptionalType?stringDefault valuenull

$username

OptionalType?stringDefault valuenull

$password

OptionalType?stringDefault valuenull

$database

OptionalType?stringDefault valuenull

$port

OptionalType?intDefault valuenull

$socket

OptionalType?stringDefault valuenull

$flags

OptionalTypeintDefault value0

$flags accepts one or a bitmask of the following constant values:

Return value

Typebool

Changes to the mysqli_real_connect Function

PHP 8.2

PHP 8.0

  • Return type added: bool
  • Parameter name of parameter #1 changed: $link to $mysql
  • Parameter type added for parameter #1 ($mysql): mysqli
  • Parameter name of parameter #2 changed: $host to $hostname
  • Parameter type added for parameter #2 ($hostname): ?string
  • Parameter default value added for position #2 ($hostname): null
  • Parameter name of parameter #3 changed: $user to $username
  • Parameter type added for parameter #3 ($username): ?string
  • Parameter default value added for position #3 ($username): null
  • Parameter type added for parameter #4 ($password): ?string
  • Parameter default value added for position #4 ($password): null
  • Parameter type added for parameter #5 ($database): ?string
  • Parameter default value added for position #5 ($database): null
  • Parameter type added for parameter #6 ($port): ?int
  • Parameter default value added for position #6 ($port): null
  • Parameter type added for parameter #7 ($socket): ?string
  • Parameter default value added for position #7 ($socket): null
  • Parameter type added for parameter #8 ($flags): int
  • Parameter default value added for position #8 ($flags): 0
  mysqli_real_connect(
-     $link,
+     mysqli $mysql,
-     $host,
+     ?string $hostname = null,
-     $user,
+     ?string $username = null,
-     $password,
+     ?string $password = null,
-     $database,
+     ?string $database = null,
-     $port,
+     ?int $port = null,
-     $socket,
+     ?string $socket = null,
-     $flags
+     int $flags = 0
-   )
+   ): bool

mysqli_real_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