File: mysqli_real_escape_string_sjis.phpt

package info (click to toggle)
php8.4 8.4.11-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 208,108 kB
  • sloc: ansic: 1,060,628; php: 35,345; sh: 11,866; cpp: 7,201; pascal: 4,913; javascript: 3,091; asm: 2,810; yacc: 2,411; makefile: 689; xml: 446; python: 301; awk: 148
file content (44 lines) | stat: -rw-r--r-- 1,390 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
--TEST--
mysqli_real_escape_string() - sjis
--EXTENSIONS--
mysqli
--SKIPIF--
<?php
require_once __DIR__ . '/test_setup/test_helpers.inc';
$link = mysqli_connect_or_skip();
if (!mysqli_set_charset($link, 'sjis'))
    die(sprintf("skip Cannot set charset 'sjis'"));
?>
--FILE--
<?php
    require_once 'table.inc';

    var_dump(mysqli_set_charset($link, "sjis"));

    if ('?p??\\\\?p??' !== ($tmp = mysqli_real_escape_string($link, '?p??\\?p??')))
        printf("[004] Expecting \\\\, got %s\n", $tmp);

    if ('?p??\"?p??' !== ($tmp = mysqli_real_escape_string($link, '?p??"?p??')))
        printf("[005] Expecting \", got %s\n", $tmp);

    if ("?p??\'?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??'?p??")))
        printf("[006] Expecting ', got %s\n", $tmp);

    if ("?p??\\n?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??\n?p??")))
        printf("[007] Expecting \\n, got %s\n", $tmp);

    if ("?p??\\r?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??\r?p??")))
        printf("[008] Expecting \\r, got %s\n", $tmp);

    if ("?p??\\0?p??" !== ($tmp = mysqli_real_escape_string($link, "?p??" . chr(0) . "?p??")))
        printf("[009] Expecting %s, got %s\n", "?p??\\0?p??", $tmp);

    var_dump(mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, '?p')"));

    mysqli_close($link);
    print "done!";
?>
--EXPECT--
bool(true)
bool(true)
done!