1--TEST--
2mysqli_connect_error()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once 'skipifconnectfailure.inc';
8?>
9--FILE--
10<?php
11    require_once 'connect.inc';
12
13    $tmp    = NULL;
14    $link   = NULL;
15
16    // too many parameter
17    try {
18        mysqli_connect_error($link);
19    } catch (ArgumentCountError $exception) {
20        print($exception->getMessage() . "\n");
21    }
22
23    if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
24        printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
25            $host, $user, $db, $port, $socket);
26
27    if (NULL !== ($tmp = mysqli_connect_error()))
28        printf("[003] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
29
30    mysqli_close($link);
31
32    if ($link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
33        printf("[003] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
34            $host, $user . 'unknown_really', $db, $port, $socket);
35
36    if ('' === ($tmp = mysqli_connect_error()))
37        printf("[004] Expecting string/'', got %s/%s\n", gettype($tmp), $tmp);
38
39    print "done!";
40?>
41--EXPECT--
42mysqli_connect_error() expects exactly 0 arguments, 1 given
43done!
44