1--TEST-- 2new mysqli() 3--SKIPIF-- 4<?php 5 require_once('skipif.inc'); 6 require_once('skipifconnectfailure.inc'); 7 if (!get_current_user()) 8 die('skip: get_current_user() not supported'); 9 if (stristr(mysqli_get_client_info(), 'mysqlnd')) 10 die("skip: test for libmysql (different error output when using php streams"); 11?> 12--FILE-- 13<?php 14 require_once("connect.inc"); 15 16 $myhost = 'invalidhost'; 17 $link = NULL; 18 19 print "1) bail\n"; 20 if (!is_object($mysqli = new mysqli($myhost)) || ('mysqli' !== get_class($mysqli))) 21 printf("[001] Expecting NULL, got %s/%s\n", gettype($mysqli), (is_object($mysqli)) ? var_export($mysqli, true) : $mysqli); 22 23 print "2) be quiet\n"; 24 if (!is_object($mysqli = @new mysqli($myhost)) || ('mysqli' !== get_class($mysqli))) 25 printf("[002] Expecting NULL, got %s/%s\n", gettype($mysqli), (is_object($mysqli)) ? var_export($mysqli, true) : $mysqli); 26 var_dump(mysqli_connect_error()); 27 var_dump(mysqli_connect_errno()); 28 29 print "3) bail\n"; 30 if (false !== ($link = mysqli_connect($myhost))) { 31 printf("[003] Expecting boolean/false, got %s/%s\n", gettype($link), $link); 32 } 33 34 print "4) be quiet\n"; 35 if (false !== ($link = @mysqli_connect($myhost))) { 36 printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link); 37 } 38 var_dump(mysqli_connect_error()); 39 var_dump(mysqli_connect_errno()); 40 41 print "done!"; 42?> 43--EXPECTF-- 441) bail 45 46Warning: mysqli::__construct(): (HY000/200%d): %s 472) be quiet 48%s(%d) "%s" 49int(200%d) 503) bail 51 52Warning: mysqli_connect(): (HY000/200%d): %s 534) be quiet 54%s(%d) "%s" 55int(200%d) 56done! 57