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