1--TEST--
2mysqli_real_escape_string()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11    require_once("connect.inc");
12
13    require('table.inc');
14
15    if ('\\\\' !== ($tmp = mysqli_real_escape_string($link, '\\')))
16        printf("[004] Expecting \\\\, got %s\n", $tmp);
17
18    if ('\"' !== ($tmp = mysqli_real_escape_string($link, '"')))
19        printf("[005] Expecting \", got %s\n", $tmp);
20
21    if ("\'" !== ($tmp = mysqli_real_escape_string($link, "'")))
22        printf("[006] Expecting ', got %s\n", $tmp);
23
24    if ("\\n" !== ($tmp = mysqli_real_escape_string($link, "\n")))
25        printf("[007] Expecting \\n, got %s\n", $tmp);
26
27    if ("\\r" !== ($tmp = mysqli_real_escape_string($link, "\r")))
28        printf("[008] Expecting \\r, got %s\n", $tmp);
29
30    if ("foo\\0bar" !== ($tmp = mysqli_real_escape_string($link, "foo" . chr(0) . "bar")))
31        printf("[009] Expecting %s, got %s\n", "foo\\0bar", $tmp);
32
33    mysqli_close($link);
34
35    try {
36        mysqli_real_escape_string($link, 'foo');
37    } catch (Error $exception) {
38        echo $exception->getMessage() . "\n";
39    }
40
41    print "done!";
42?>
43--EXPECT--
44mysqli object is already closed
45done!
46