xref: /PHP-8.1/ext/spl/tests/array_018.phpt (revision ea256a21)
1--TEST--
2SPL: ArrayObject and \0
3--FILE--
4<?php
5
6try
7{
8    $foo = new ArrayObject();
9    $foo->offsetSet("\0", "Foo");
10}
11catch (Exception $e)
12{
13    var_dump($e->getMessage());
14}
15
16var_dump($foo);
17
18try
19{
20    $foo = new ArrayObject();
21    $data = explode("=", "=Foo");
22    $foo->offsetSet($data[0], $data[1]);
23}
24catch (Exception $e)
25{
26    var_dump($e->getMessage());
27}
28
29var_dump($foo);
30
31?>
32--EXPECTF--
33object(ArrayObject)#1 (1) {
34  ["storage":"ArrayObject":private]=>
35  array(1) {
36    ["%0"]=>
37    string(3) "Foo"
38  }
39}
40object(ArrayObject)#2 (1) {
41  ["storage":"ArrayObject":private]=>
42  array(1) {
43    [""]=>
44    string(3) "Foo"
45  }
46}
47