1--TEST--
2$mysqli->error
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 ('' !== ($tmp = @$mysqli->error))
17        printf("[001] Expecting empty string, 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    $tmp = $mysqli->error;
24    if (!is_string($tmp) || ('' !== $tmp))
25        printf("[003] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error);
26
27    if (!$mysqli->query('DROP TABLE IF EXISTS test')) {
28        printf("[004] Failed to drop old test table: [%d] %s\n", $mysqli->errno, $mysqli->error);
29    }
30
31    $mysqli->query('SELECT * FROM test');
32    $tmp = $mysqli->error;
33    if (!is_string($tmp) || !preg_match("/Table '\w*\.test' doesn't exist/su", $tmp))
34        printf("[006] Expecting string/[Table... doesn't exit], got %s/%s. [%d] %s\n", gettype($tmp), $tmp, $mysqli->errno, $mysqli->error);
35
36    $mysqli->close();
37
38    try {
39        $mysqli->error;
40    } catch (Error $exception) {
41        echo $exception->getMessage() . "\n";
42    }
43
44    print "done!";
45?>
46--EXPECT--
47mysqli object is already closed
48done!
49