xref: /PHP-7.3/ext/standard/tests/strings/pack_Z.phpt (revision 4d8d5d83)
1--TEST--
2pack()/unpack(): "Z" format
3--FILE--
4<?php
5var_dump(
6	pack("Z0", "f"),
7    pack("Z5", "foo\0"),
8    pack("Z4", "fooo"),
9    pack("Z4", "foo"),
10	pack("Z*", "foo"),
11    unpack("Z*", "foo\0\rbar\0 \t\r\n"),
12    unpack("Z9", "foo\0\rbar\0 \t\r\n"),
13    unpack("Z2", "\0"),
14    unpack("Z2", "\0\0"),
15    unpack("Z2", "A\0"),
16    unpack("Z2", "AB\0"),
17    unpack("Z2", "ABC")
18);
19--EXPECTF--
20Warning: unpack(): Type Z: not enough input, need 2, have 1 in %s on line %d
21string(0) ""
22string(5) "foo%c%c"
23string(4) "foo%c"
24string(4) "foo%c"
25string(4) "foo%c"
26array(1) {
27  [1]=>
28  string(3) "foo"
29}
30array(1) {
31  [1]=>
32  string(3) "foo"
33}
34bool(false)
35array(1) {
36  [1]=>
37  string(0) ""
38}
39array(1) {
40  [1]=>
41  string(1) "A"
42}
43array(1) {
44  [1]=>
45  string(2) "AB"
46}
47array(1) {
48  [1]=>
49  string(2) "AB"
50}
51