1--TEST--
2$mysqli->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    $mysqli = new mysqli();
16    if (0 !== ($tmp = @$mysqli->errno))
17        printf("[001] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
18
19    if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))
20        printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
21            $host, $user, $db, $port, $socket);
22
23    var_dump($mysqli->errno);
24
25    if (!$mysqli->query('DROP TABLE IF EXISTS test')) {
26        printf("[003] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error);
27    }
28
29    $mysqli->query('SELECT * FROM test');
30    var_dump($mysqli->errno);
31
32    @$mysqli->query('No SQL');
33    if (($tmp = $mysqli->errno) === 0)
34        printf("[004] Expecting int/any non zero got %s/%s\n", gettype($tmp), $tmp);
35
36    $mysqli->close();
37
38    try {
39        $mysqli->errno;
40    } catch (Error $exception) {
41        echo $exception->getMessage() . "\n";
42    }
43
44    print "done!";
45?>
46--EXPECTF--
47int(0)
48int(%d)
49mysqli object is already closed
50done!
51