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