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