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